one way to debug upstart init configurations

upstart init configurations can be tough to debug sometimes. for instance, i was trying to figure out why a shell script that runs as a daemon wouldn’t start. the configuration was simple enough:


# /etc/init/foo.conf
start on runlevel 3
  exec /usr/local/bin/foo start
end script

turns out, that the script was using sudo to relaunch itself as an unprivileged user. well, sudo requires a terminal. at least, that’s what the error message said, and i didn’t feel like doing a lot of research. i just changed the line from sudo to su -c. point is, i wouldn’t have seen the error (for a couple of reasons) without the following:

# /etc/init/initdebugger.conf
start on (starting JOB!=debug or started JOB!=debug or stopping JOB!=debug or stopped JOB!=debug )
  exec >>/tmp/initdebugger 2>>/tmp/initdebugger
end script

the following will generally work…

cp initdebugger.conf /etc/init
initctl reload-configuration
initctl list
initctl start initdebugger
initctl start foo
tail /var/log/messages