How to use CHEF to run JAR? [closed]
-
23-12-2019 - |
Question
I have a working jar file on a ubuntu virtual machine. I need to create a Chef recipe to:
- Execute jar - (eg: run the command: java -jar name.jar)
- Stop the execution - when new jar is deployed.
Could it be achieved by CHEF?
Regards, Aditya Chaudhary
Solution
There are lots of options out there. The simplest is probably:
execute "run file.jar in directory" do
command "java -jar file.jar"
cwd "directory containing jar file"
action :run
end
The jar command will return an error code that Chef will use to determine success or failure. There are many ways to do this with Chef. You can see how others recommended running the jar command in the backround here if you need to move on after this command: Jar execution in background
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow