如何避免Rufus调度程序被调用多次,因为没有dynos? [英] How to avoid Rufus scheduler being called as many times as there are no.of dynos?

查看:111
本文介绍了如何避免Rufus调度程序被调用多次,因为没有dynos?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Heroku 中运行了一个rails应用程序,并使用 Rufus Scheduler



我的应用程序使用多个 dyno 并且调度程序在每个 dyno 上运行,而不仅仅是一个,所以我的预定事件会多次触发(每个 dyno )。



我该如何避免这种情况?

解决方案

web:unicorn -c app / config / unicorn.rb ...#您现有的网络动态进程
scheduler:rake rufus:scheduler#为rufus调度程序进程添加rake任务

您可以使用 heroku ps:scale 设置一个调度程序dyno和N个网页dynos。

编辑

一个Rails应用程序目前包含rufus调度程序。当您将该应用程序部署到Heroku时,您的Rails应用程序代码和所需库将安装在每个测试仪上(通过一个或多个构建包)。 dyno是一个在您的应用程序中运行进程的虚拟机。

默认情况下,您有一个运行Rails Web应用程序服务器的dyno。如果添加第二种类型的测试仪,它将具有相同的代码库和库,但运行不同的过程。在这种情况下,第二个过程将成为您的Rufus调度程序进程。


I am running a rails app in Heroku where I use Rufus Scheduler.

My app uses more than one dyno and the scheduler is running on each dyno rather than just one, so my scheduled events are firing multiple times (once for each dyno).

How can I avoid this?

解决方案

You should add a new process type in your Procfile that runs your Rufus scheduler process:

web: unicorn -c app/config/unicorn.rb ... # Your existing web dyno process
scheduler: rake rufus:scheduler # Add rake task for rufus scheduler process

You can then use heroku ps:scale to set one scheduler dyno and N web dynos.

EDIT

You have a Rails application which currently contains your rufus scheduler. When you deploy that application to Heroku, your Rails application code and required libraries are installed on each dyno (via one or more buildpacks). The dyno is a virtual machine that runs a process within your application.

By default, you have a dyno that runs a Rails web app server. If you add a second type of dyno, it will have the same codebase and libraries, but run a different process. In this case, that second process will be your Rufus scheduler process.

这篇关于如何避免Rufus调度程序被调用多次,因为没有dynos?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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