3

In my Rails app on Heroku, I want to execute a simple block of code at 5 specific times in the future (each about a day apart), down to the second.

Is there a good way to do this without a background process?

I don't want to use Delayed Job because it'll require a Worker instance that costs ~$30/month. Seems unnecessary.

Is there a GOOD way to do this without Delayed Job / a Heroku Worker?

Resolved

Thanks for your answers- looks like there isn't a solid way to accomplish this. Going with Delayed Job.

4

4 回答 4

1

改用 rake 任务和 heroku 调度程序

https://devcenter.heroku.com/articles/scheduler

调度程序附加组件将运行一次性进程,这些进程将计入您当月的 dyno-hours。

于 2012-05-15T02:38:33.860 回答
1

您可以使用调度程序来执行此操作,您只需要在任务运行时检查日期/小时等 - 因此您可以安排每小时作业(如果这对您有用),然后检查当前日期/小时以查看是否这是您要在其中运行作业然后在支票内运行它的作业。不理想,但会工作。

于 2012-05-15T08:22:09.137 回答
1

您可以将 Rake 任务与 Heroku 调度程序一起使用,然后添加一些智能逻辑:sleep until job_is_available if job_is_available_in_less_than_twelve_minutes?

然后,您需要支付运行代码的时间,以及您的 rake 任务检查作业是否可用所需的几秒钟。大约 1-3 美元,因为 Heroku 按比例计算第二个。

于 2012-05-15T06:28:01.977 回答
1

老问题,但是...

也许它可以解决你的问题:Sucker Punch

Heroku 上不需要额外的测功机。并且可以指定 5 个块之间的时间。

于 2015-06-03T02:41:05.000 回答