I just started working with Advanced Queues with the Commerce Billing module.
My D7 test site currently runs cron tasks via crontab:
*/15 * * * * /usr/bin/drush --root=/var/www/html --quiet cron
But it seems that the Advanced Queues aren't run with that task. I had to add this additional task to my crontab to get the queues to process:
*/15 * * * * /usr/bin/drush --root=/var/www/html advancedqueue --all --timeout=60
It looks like there's a way to run Advanced Queues via "poor-man's" processing via cron in the docs, but I'm not quite sure how to accomplish that.
Of course, I also don't know what 'best practice' is for running Advanced Queues in general. Are two lines in crontab a better way to go?
Thanks for any support!
Comments
Comment #2
cmarcera CreditAttribution: cmarcera commentedComment #3
cmarcera CreditAttribution: cmarcera commentedFor now I've settled with the following cron schedule:
Still not sure if that is reasonable or what best practice is. I'd still love any feedback!
Comment #4
nvahalik CreditAttribution: nvahalik at Code and Salt commentedThere are two methods that I've personally used to run AQs. The first is the crontab and the second is a process manager.
Using crontab
Crontab can be an effective way to handle your queue jobs. As you already pointed out the use of the
--timeout
param lets you specify how long you want that queue worker to live and it's generally a good idea to keep it right around the time of the jobs. Note that running multiple queue workers can be OK, too. If you want to run more, you can "ramp up" by doing a job that runs every minute and having runners that run for 3 minutes, or jobs that run every 5 minutes but last for 15.There are several things to take into consideration here:
Using a process manager
The other way to do this would be to use some sort of a process manager. A process manager will keep the process alive until it is either killed or if the process itself signals that it wants to exit gracefully. In a recent project, I've used a combination of the
screen
command along with a bash function calledforever
to run AQ workers until they either signal for exit.There are some caveats with this approach too:
Here's a copy of the
forever
"process manager", which is really just a bash script that restarts processes unless the process sends a signal saying that it is done.Note that these commands are to be used in tandem with the patch in this issue: #2916304: Support signal handling in drush process queue command.
Comment #5
nvahalik CreditAttribution: nvahalik at Code and Salt commentedBTW I'm marking this as closed—but if docs need to be updated we can certainly do so.