Last Updated: February 25, 2016
·
5.439K
· atlantageek

upstart, a builtin alternative to God and monit

Upstart is an event driven replacement of SysV init process, upstart ships with RHEL, CentOS, Fedora and Ubuntu.

If you are familiar with linux you know of the classic /etc/init.d directory where you list all your scripts that start and stop processes then you create links like /etc/init5/S47http that will point to the http startu scrip. This will signify that on boot level 5 start http after all the other processes that are start with S00 - S46 have started. There would be a corresponding U process.

upstart changes this. In the directory /etc/init (on rhel) you specify what events should happen before you start the target script. So for instance my delayed_job looks like:

description "DELAYED JOB"
author      "Tommie Jones"

start on (local-filesystems 
    and net-device-up
    and runlevel [2345])
stop on runlevel [!2345]

chdir /var/www/vanguard
exec /usr/bin/env RAILS_ENV=production rake jobs:work >>     
/tmp/upstart.log 2>&1

respawn

respawn limit 10 90

This config file says wait till the local files system is running, the network is up and one of the run levels 2-5 are up. If all this is up then change the directory and run delayed job.

So its easier to define how a job is started. what allows this to replace god and monit is 'respawn' .

respawn will relaunch a process if it dies. And the respawn limit says if it is respawned more than 10 times in 90 seconds then giveup.

Each command is called a stanza and there are even more stanzas available. Check it out at

http://upstart.ubuntu.com/wiki/Stanzas