Setting sleep time in delayed job

核能气质少年 提交于 2019-12-11 07:25:29

问题


Ok,a simple question. I want to change sleep time for my delayed job worker. How do I do it in the current version?

I've found out two suggestions for this:

Delayed::Worker.const_set("SLEEP", sleep_time_in_seconds)

and

Delayed::Worker.sleep_delay = sleep_time_in_seconds.

What's the difference between those two?

Thanks


回答1:


It depends on what version of delayed_job you are using. If you are using the tobi version (https://github.com/tobi/delayed_job) you should set the constant:

Delayed::Worker.const_set('SLEEP', sleep_time_in_seconds)

If you don't know what version you are using, the tobi version is most likely it (you can check the delayed_job.gemspec file in your plugin directory to confirm; it will have something like s.homepage = <git-page-of-your-version>).

If you are using the collectiveidea version (https://github.com/collectiveidea/delayed_job) you should use the attribute setter:

Delayed::Worker.sleep_delay = sleep_time_in_seconds

If you are using another version, consult the README for that version.



来源:https://stackoverflow.com/questions/8596702/setting-sleep-time-in-delayed-job

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!