Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use CHEF to run JAR? [closed]

I have a working jar file on a ubuntu virtual machine. I need to create a Chef recipe to:

  1. Execute jar - (eg: run the command: java -jar name.jar)
  2. Stop the execution - when new jar is deployed.

Could it be achieved by CHEF?

Regards, Aditya Chaudhary

like image 651
Java User Avatar asked Oct 21 '22 04:10

Java User


1 Answers

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

like image 61
Display Name is missing Avatar answered Oct 23 '22 10:10

Display Name is missing