upstart script

A Upstart script have to be placed at /etc/init/, ending with .conf.
It requires 2 sessions: one to indicate when to start, and another with the command to exec.
The easiest script to start with your sample is:
# myprogram.conf
start on filesystem
exec /usr/bin/java -jar /path_to/program
Created as root under /etc/init/myprogram.conf.
If your script requires more than one command line, use the script section instead of the exec line:
# myprogram.conf
start on filesystem
script
    /usr/bin/java -jar /path_to/program
    echo "Another command"
end script
To enable bash completion for your service, add a symlink into /etc/init.d folder:
sudo ln -s /etc/init/myprogram.conf /etc/init.d/myprogram
Then try start and stop it:
sudo service myprogram start
According the upstart cookbook, you can create pre-start/post-start and pre-stop/post-stopcommands to be executed.
Additionally, I read you want to check if a process is running. Check this question and maybe use the pre-start section

Comments

Popular posts from this blog

HAproxy logging

teamcity Automatic Agent Start under Linux

NFS mount add in fstab _netdev instead of default | firewall-cmd --list-all