简体   繁体   English

在Heroku + localhost上调度Rails任务

[英]Scheduling Rails tasks on Heroku+localhost

Is there a scheduling gem/app/add-on that works on both Heroku and my local machine? 是否有适用于Heroku和本地计算机的调度gem / app / add-on? I just need to run a single task daily, so I don't think I need anything too complicated. 我只需要每天运行一个任务,所以我认为我不需要太复杂的任何事情。

I've looked at Heroku's Scheduler, but it doesn't look like there's anything comparable locally for that. 我看过Heroku的调度程序,但它看起来并不像本地的任何东西。 The whenever gem doesn't have anything comparable on Heroku ( "Whenever" gem running cron jobs on Heroku .) I also looked at Resque/Resque Scheduler/Redis, but it really seems like overkill for what I want to do. 每当宝石在Heroku上没有任何可比性( “Whenever”宝石在Heroku上运行cron作业 。)我也看了Resque / Resque Scheduler / Redis,但它看起来真的有点像我想做的事。

Am I missing something really basic here? 我错过了一些非常基本的东西吗?

If you use the Heroku Scheduler on Heroku you can just use your locally crontab (assuming you're using OSX/Linux) to run things locally. 如果您在Heroku上使用Heroku Scheduler,您可以使用本地crontab(假设您使用的是OSX / Linux)在本地运行。 All Heroku Scheduler is doing is executing a rake task at a given time, nothing too complicated in that. 所有Heroku Scheduler正在执行的是在给定时间执行rake任务,没有什么太复杂的。

rufus-scheduler works both locally or remotely on Heroku, ... with some limitations : rufus-scheduler在Heroku上本地或远程工作,...有一些限制:

1) long-running job will be terminated: scheduled jobs are meant to execute short running tasks or enqueue longer running tasks into a background job queue such as Delayed Job . 1)长时间运行的作业将被终止:预定作业用于执行短期运行任务或将较长时间运行的任务排入后台作业队列(如延迟作业) Anything that takes longer than a couple of minutes to complete should use a worker process to run ( see: heroku scheduler add-on ) 任何需要花费超过几分钟才能完成的操作应该使用工作进程来运行(请参阅: heroku scheduler add-on

2) you'll have to be careful about memory consumption. 2)你必须小心内存消耗。 Each process has a 512 MB memory limit, after which it starts paging to swap and performance is degraded. 每个进程都有512 MB的内存限制,之后它开始分页以进行交换,性能降低。 If all of your threads combined use less than 512 MB of memory, then this might work. 如果所有线程组合使用的内存少于512 MB,那么这可能会起作用。

I am using the scheduler on heroku and things are working fine. 我在heroku上使用调度程序,一切正常。 If you want the same thing setup locally, you can just create cron task that just runs the rake task at the same iteration. 如果你想在本地设置相同的东西,你可以创建只在同一次迭代中运行rake任务的cron任务。

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

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