Ubuntu upstart hangs on interactive start & stop

Ubuntuupstartxen

How do I get Ubuntu upstart to not hang on interactive start & stop?

I have created many upstart scripts that work fine during init, but often hang when I enter them at the console. If I CTRL+C out, all that happens is that the job changes state. The script is never run.

I’m running Ubuntu Lucid on a Xen virtual server with a Linux 2.6.39 kernel.

Below is merely a representative example of many scripts that behave this way:

description "apache2"

start on local-filesystems \
  and (net-device-up IFACE=lo) \
  and (runlevel [2345])
stop on runlevel [016]

respawn
respawn limit 10 5

expect daemon

script
  . /etc/apache2/envvars
  /usr/sbin/apache2ctl start
end script

Best Answer

Check out my question on askubuntu.com about the same thing:

https://askubuntu.com/questions/3126/upstart-supervised-init-script-for-apache

In the example you posted, it would come down to directly executing the apache binary vs. executing the apache2ctl script. Upstart expects the process it starts to not die immediately, basically; which is exactly what apache2ctl does.

There's a working Apache upstart script on my askubuntu.com question.