[英]Run clockwork only on one production instance (rails capistrano)
I have a production server with two instances app1 and app2 to which I use capistrano to deploy my application, ie: cap app1 deploy, cap app2 deploy. 我有一个具有两个实例app1和app2的生产服务器,我使用capistrano来向其部署我的应用程序,即:cap app1 deploy,cap app2 deploy。
I am now configuring the clockwork to schedule my delayed jobs. 我现在正在配置发条以安排延迟的工作。 But what happens the jobs are scheduled twice, because the clockwork process runs on both app1 and app2 after application is deployed.
但是将作业安排两次,因为部署应用程序后,发条流程同时在app1和app2上运行。
How can I force the capistrano to run the clockwork process only on app2 ? 如何强制capistrano仅在app2上运行发条过程?
Thanks for a hint. 感谢您的提示。 Miroslav
米罗斯拉夫
Add the following settings into the deploy.rb: 将以下设置添加到deploy.rb中:
set :clockwork_role, :clock
And then configure only one of the instances to use the role :clock, ie: 然后仅配置一个实例使用角色:clock,即:
server 'URL', user: 'deploy', roles: %w{app db web clock}
In your case you can set some config variable to true
in one case, and to false
in the second, and check it when setting clockwork. 在您的情况下,您可以将某些配置变量设置为
true
,然后将其设置为false
,并在设置发条时进行检查。
But want to mention that you are using different 'stages' (which are usually 'staging', 'production', 'qa', 'features', etc) for the different servers of one stage. 但是要提及的是,您为一个阶段的不同服务器使用了不同的“阶段”(通常是“阶段”,“生产”,“质量保证”,“功能”等)。 Capistrano has 'roles' (app, db, background jobs, etc) each can have several servers.
Capistrano具有“角色”(应用,数据库,后台作业等),每个角色可以具有多个服务器。
Also please mention which capistrano version you're using - there were big changes from 2 to 3 还请说明您使用的是哪个版本的capistrano-从2到3的变化很大
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.