gearman-ruby
gearman-ruby copied to clipboard
Is it possible to control the times of running job?
In gearman command line tool, it allow to control the times of run before exiting.
-c <count> - Number of jobs for worker to run before exiting
The goal: one worker takes one job and stop by itself.
Try: I set the @worker_enabled to false, after taking the job. However, it doesn't stop after the job finished. And it stop after the queue is empty. Doesn't work like we expected
I think the reason is that end while type == :job_assign
in the worker.rb
It could definitely be implemented; I'm curious what your use case is for this (aside from the obvious "take one job and stop" :))
Hi John, thanks for replying. I override the end while type == :job_assign
to end while type == :job_assign && worker_enabled
. Just would like to make sure worker_enabled can be applied immediately. It doesn't have to be taking only one job. The purpose is that we are able to control the gearman inside worker instead of killing the process.