开发者

Is there a way to run multiple instances of DelayedJob in Rails?

开发者 https://www.devze.com 2023-04-09 16:27 出处:网络
I don\'t mean multiple processes, I mean separate instances. I think. I may be going about this the wrong way.

I don't mean multiple processes, I mean separate instances. I think. I may be going about this the wrong way.

Right now dj handles 2 things in my application: Reports and image processing/upload. The problem is, People can create a WHOLE bunch of report jobs whenever they want, and there are no processes left over to do the images until after all those reports ar开发者_开发知识库e run.

How can I set up DelayedJob so that I can always have at least one proc dedicated to a particular function?

This is collectiveidea's fork of DelayedJob, running on Rails 2.3.8.


You can set a priority for delayed jobs which may address your problem. Set the reporting jobs to be a lower priority than the image processing and they'll be done only when there's no images to be processed.

Using handle_asynchronously with a priority is covered in the readme but the syntax is basically:

handle_asynchronously :my_method, :priority => 5

By default everything is priority zero which is the highest priority.


DelayedJob 3.0.0pre supports named queues so you can have pools of workers for jobs coming through different queues.

0

精彩评论

暂无评论...
验证码 换一张
取 消