سؤال

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

هل كانت مفيدة؟

المحلول

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top