respawn does not work for daemon or fork process

Kelvin Chan Kelvin.T.Chan at Verizon.net
Wed Oct 8 15:30:38 BST 2008


respawn does not seem to work for daemonized  or forked process.

I have a 'systembus' job to launch & respawn the dbus-daemon, it look  
like this:

# DBUS system daemon
#
# started until it is shut down again.

start on stopped rc2 or stopped rc3 or stopped rc4 or stopped rc5
stop on runlevel 0 or runlevel 6

export PATH=/opt/upstart/sbin:$PATH

respawn
respawn limit 4 60

expect fork
exec /usr/bin/dbus-daemon --fork --system

I found that the dbus-daemon did not get respawn when it was killed.
After I killed dbus-daemon, the dbus-daemon process was gone (not  
shown on ps command).
But upstart initctl reported dbus-daemon still in running state.

Here are the steps I performed:

1) I listed the dbus-daemon process to make sure it was started. It  
had pid 1031:
bash-3.00# ps axg | grep dbus-daemon
  1031 ?        Ss     0:00 /usr/bin/dbus-daemon --fork --system
  1062 ?        R+     0:00 grep dbus-daemon

2) I checked the job status and upstart reported it's running:
bash-3.00# /opt/upstart/sbin/initctl status systembus
systembus running

3) I killed the dbus-daemon process, and verified pid 1031 was  
actually got kill:
bash-3.00# pidof dbus-daemon | xargs kill
bash-3.00# ps axg | grep dbus-daemon
  1068 ?        R+     0:00 grep dbus-daemon

4) I noticed upstart did not respawn the dbus-daemon after it was  
killed.
Upstart reported the dbus-daemon (or systembus job) is still running:
bash-3.00# /opt/upstart/sbin/initctl status systembus
systembus running

5) After I had explicitly stopped & started the job again,
I did not see upstart respawn the dbus-daemon.
Although upstart reported that dbus-daemon is running:

bash-3.00# /opt/upstart/sbin/initctl stop systembus
bash-3.00# /opt/upstart/sbin/initctl status systembus
systembus not running

bash-3.00# ps axg | grep dbus-daemon

bash-3.00# /opt/upstart/sbin/initctl start systembus
init: systembus main process (1079) killed by TRAP signal
init: systembus main process ended, respawning

bash-3.00# /opt/upstart/sbin/initctl status systembus
systembus running

bash-3.00# ps axg | grep dbus-daemon

/Kelvin Chan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.ubuntu.com/archives/upstart-devel/attachments/20081008/cb4126a8/attachment.htm 


More information about the upstart-devel mailing list