whenever gem have cronjob on only one machine?

孤人 提交于 2019-12-20 10:34:47

问题


We have a large deployment of around a dozen servers. We'd like to use the Whenever gem but I can't figure out a way to say which machine the cron jobs should go on! We only want these jobs to run on our server that does background jobs.

Is there a way to specify this?


回答1:


If you deploy the project with Capistrano and you use the default Whenever recipe, you can create a new Capistrano role

role :whenever, "192.168.1.1"

and set the role in your deploy.rb file

set :whenever_roles, "whenever"

In this way, the task will be executed only on the specified server.




回答2:


whenever is preconfigured to run against the db role, so if your db role is also the background machine's role you don't have to do the 'role :whenever, "192.168.0.1"' hack. see the codes

https://github.com/javan/whenever/blob/master/lib/whenever/capistrano.rb#L2



来源:https://stackoverflow.com/questions/5065109/whenever-gem-have-cronjob-on-only-one-machine

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