gearman-ruby icon indicating copy to clipboard operation
gearman-ruby copied to clipboard

Is it possible to control the times of running job?

Open runpengchensc opened this issue 7 years ago • 3 comments

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

runpengchensc avatar May 01 '17 21:05 runpengchensc

I think the reason is that end while type == :job_assign in the worker.rb

runpengchensc avatar May 01 '17 23:05 runpengchensc

It could definitely be implemented; I'm curious what your use case is for this (aside from the obvious "take one job and stop" :))

johnewart avatar May 02 '17 17:05 johnewart

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.

runpengchensc avatar May 02 '17 23:05 runpengchensc