I'm running a resque worker service on Ubuntu, and I want to manage it using upstart (the default process manager for Ubuntu).
A proper shutdown sequence for a resque worker is to send the
QUIT signal first, and wait for the process to finish any running job first. It should then stop itself. If the worker doesn't shutdown in a timely manner - because the job is still running (possibly stuck), I need to send a
TERM signal which will cause the worker process to abort the job and exit. And obviously, if that doesn't work, a
KILL signal would have to be sent.
The way I thought to implement this is to have a
pre-start script to send the
QUIT signal and then sleep until either the process exists or a timeout expires.
But in effect what happens is that if the worker responds to
QUIT and exits,
respawn kicks in and restarts the process which apparently causes the stopping process to not happen.
Is there a way to get upstart to not respawn if we are stopping the process anyway?