Upstart service is not killing processes on stop

upstart

I have an upstart service that maintains a number of instances of workers.

pm-all-workers.conf:

start on runlevel [2345]
stop on runlevel [!2345]

env NUM_WORKERS=25

pre-start script
for i in `seq 1 $NUM_WORKERS`
  do
    start pm-worker N=$i
  done
end script

pm-worker.conf:

start on runlevel [2345]
stop on stopping pm-all-workers

instance $N
respawn
respawn limit 10 5
umask 022

exec su - someuser -c "/home/someuser/bin/worker.bin"

This has been working fine, but recently some of the worker processes keep hanging around even if the service is stopped. My understanding is upstart will send SIGTERM to the processes on stop and then after a few seconds SIGKILL, if the process is still up.

How is it possible that some processes don't get killed? I can kill the processes fine manually with pkill -9 worker.bin.

Best Answer

Perhaps Upstart is sending su the SIGTERM/KILL, instead of your worker.bin. Try using the setuid stanza of upstart and remove the su bit.

Related Topic