每当 gem 在一台机器上有 cronjob 时? [英] whenever gem have cronjob on only one machine?

查看:29
本文介绍了每当 gem 在一台机器上有 cronjob 时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有大约十几台服务器的大规模部署.我们想使用Whenever gem,但我想不出一种方法来说明cron作业应该在哪台机器上进行!我们只希望这些作业在我们执行后台作业的服务器上运行.

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.

有没有办法指定这个?

推荐答案

如果你使用 Capistrano 部署项目并且你使用默认的 Whenever recipe,你可以创建一个新的 Capistrano 角色

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"

并在您的 deploy.rb 文件中设置角色

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.

这篇关于每当 gem 在一台机器上有 cronjob 时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆