Exit after X jobs processed

57 views
Skip to first unread message

Kim Dowling

unread,
Aug 1, 2019, 8:09:43 AM8/1/19
to delayed_job
Is it possible to have a worker exit after a certain number or processed jobs?

We are currently starting workers with a wrapper script containing:
require 'delayed/command'
Delayed::Worker.logger = Logger.new(STDOUT)
Delayed::Command.new(ARGV).daemonize
which is executed like "bundle exec ./script/delayed_job_runner --queue=${queueName} -n ${workerCount} run"

We have a use case where we would like to terminate workers after they process a number of jobs.
There doesnt appear to be a command line argument that would suit, and the queues always have jobs in them so the work till empty options will not work.

Ideally i would love to have a `--exit-after X` command line flag instead of using `Delayed::Command.new(ARGV).daemonize` or maybe wrap it in a block that can do the counting in my own codebase?



Kurt Werle

unread,
Feb 14, 2020, 3:29:36 PM2/14/20
to delayed_job
Kim,
Did you ever come up with a solution to this?  From looking at the code it seems like workers process 100 jobs at a time, but I'm not sure if they die after that or just pick up another 100 jobs.
Reply all
Reply to author
Forward
0 new messages