.

Coffee Powered

code and content

Restarting Resque workers (or anything, really) with Monit, Passengers-style.

Easy way to trigger off a reload of a service managed by Monit without having to become root. In my case, I’ve got a monit service called resque-worker, and I can restart it by just touching tmp/resque-restart.txt.

check file resque-restart.txt with path /path/to/your/app/tmp/resque-restart.txt
  if changed timestamp then
    exec "/usr/bin/monit restart resque-worker"

Ties in nicely with deploy tasks, and you don’t have to end up leaving root access SSH keypairs laying around.

  • Brandon Wilburn

    Do you mind posting your resque-worker service file?

    I am currently following Monit tutorials but am a bit unsure if the resque workers generate a PID file somewhere (I haven’t seen one yet, can’t say I’ve been looking either).I configured my monit daemon which is working nicely, just a bit unsure how your ‘touch /resque-restart’ is working. Do you mind elaborating?

  • Chris Heald

    The workers do indeed generate PIDs. This is how I’m managing my workers: http://pastie.org/private/pw9s2ju0pqzinsn3u4lhiw - the touch job just invokes a restart on the “proper” management job.