简体   繁体   English

在负载均衡器后面跟踪计划的任务

[英]Rails scheduled task behind a load balancer

I was wondering how to properly schedule a task for a rails application that sits behind an elastic load balancer. 我想知道如何为弹性负载均衡器后面的Rails应用程序正确安排任务。

This task is an automated weekly email that is to be sent out every Monday from the application. 此任务是每周自动发送的电子邮件,该电子邮件将在每个星期一从应用程序发送出去。 We currently have multiple EC2 instances that sit behind a LB. 当前,我们有多个EC2实例位于LB后面。

I was going to use the whenever gem in order to accomplish this and have the schedule in the code repo, but thought it would attempt to run the task from all of our instances. 我打算使用everyth gem来完成此任务,并在代码存储库中安排时间表,但是我认为它将尝试从所有实例中运行任务。

What can I do to run a scheduled rake task once per week on servers behind a load balancer? 如何每周在负载均衡器后面的服务器上运行计划的rake任务?

As zwippie said 正如zwippie所说

Perhaps this converation is still relevant, it mentions that the tasks will only run on the machine with the :db role. 也许这种转换还是有意义的,它提到任务将仅在具有:db角色的计算机上运行。

I believe that roles are the best solution to this problem currently. 我认为,角色是当前解决此问题的最佳方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM