dannyman.toldme.com


Linux, Technical

Quick and Dirty Upstart

I want to launch a service which has its own complex start/stop script at boot, and I want to launch it as a non-login user. So, I dig into upstart. The cookbook … is not a cookbook. So, here’s is my little recipe:

# /etc/init/openfire.conf
description "Run OpenFire Jabber Server"
start on runlevel [2345]
stop on runlevel [!2345]
setuid openfire
setgid openfire
pre-start exec /opt/openfire/bin/openfire start
post-stop exec /opt/openfire/bin/openfire stop

All this does is, run /opt/openfire/bin/openfire start or /opt/openfire/bin/openfire stop at the appropriate time. Allegedly, this is suboptimal, but it works for me.

I tested with:

sudo start openfire
sudo stop openfire
sudo reboot # :)

Another sample, where the idiom is “cd to a directory and run a command:”

# /etc/init/haste-server.conf
description "Private Pastebin Server"
start on runlevel [2345]
stop on runlevel [!2345]
setuid haste
setgid haste
console log
script
  cd /opt/haste-server
  npm start
end script
#respawn

Thank you, htorque on askubuntu!

Read More

Next:
Previous:
Categories: Linux, Technical

Discover more from dannyman.toldme.com

Subscribe now to keep reading and get access to the full archive.

Continue reading