php-resque : How to pause and stop a worker from php script

1.2k Views Asked by At

PHP-Resque workers can be started from a script with something like

passthru("nohup php " . __RESQUE_BIN__ . " >> " . __RESQUE_LOG__ . " 2>&1 &");

But how do i pause them, or stop them from a php script ?

1

There are 1 best solutions below

2
On

Check the README, you can send signals to worker processes to do what you ask:

  • QUIT - Wait for child to finish processing then exit
  • TERM / INT - Immediately kill child then exit
  • USR1 - Immediately kill child but don't exit
  • USR2 - Pause worker, no new jobs will be processed
  • CONT - Resume worker.

You will need the pid of the worker, you can send a signal with posix_kill