Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'monit stop all' doesn't actually kill the php-resque-scheduler worker #16

Open
chuanma opened this issue May 27, 2013 · 2 comments
Open

Comments

@chuanma
Copy link

chuanma commented May 27, 2013

We use the exact stop command provided with php-resque-scheduler:

stop program = "/bin/sh -c 'kill -s QUIT cat /var/run/resque/scheduler-worker.pid && rm -f /var/run/resque/scheduler-worker.pid; exit 0;'"

We found that the pid file was removed, but the scheduler worker wasn't killed. What would be the root cause of that? Could we use kill -9 if kill -s QUIT doesn't work?

@danhunsaker
Copy link
Contributor

kill -9 will always work, but by definition it never allows an application to properly clean up after itself. I would personally recommend against it whenever possible.

That said, the scheduler itself doesn't intercept any signals, so PHP should be handling that automatically. When you start php-resque-scheduler, are you starting it in an environment with the PIDFILE variable set to /var/run/resque/scheduler-worker.pid? The easiest way to ensure this, of course, is to include it as part of the start command in your monit config: PIDFILE="/var/run/resque/scheduler-worker.pid" /path/to/php-resque-scheduler. Without that variable in the environment, the PID file never gets created, and your kill command never gets a valid PID on its command line. In fact, kill probably complains about this, but the exit 0 portion of the stop program line prevents this complaint from reaching you, except perhaps in a log file someplace.

If the script is starting in an environment that does have this variable set (you could modify bin/resque-scheduler to report the contents of this variable on start in order to verify that this is the case), then the issue lies elsewhere, and we'll probably need more details to help figure out what's up. My initial reaction, though, is that PIDFILE isn't making it all the way through to the startup script.

@chuanma
Copy link
Author

chuanma commented May 28, 2013

Thanks for the info. We just copied the monit config file from the link below. After 'monit start all', I also checked the /var/run folder and saw the pid file there. Maybe some of our jobs are not well-written. I'll take a look.

https://github.com/chrisboulton/php-resque-scheduler/blob/master/extras/resque-scheduler.monit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants