I had developed an application that has delayed job and cron job and I need to deploy it to Heroku. I realized my delayed job need Heroku adds-on, "Heroku Scheduler Standard" and it costs $34.50. 1) Does that mean I need to buy that so that my delayed and cron job will run automatically?I wonder if delayed job and cron job can be done by using Heroku schedular then why we still need javan/whenever and collectiveidea/delayed_job? Can I use these in Heroku preferably in free condition?
我开发了一个延迟了作业和cron作业的应用程序,我需要将它部署到Heroku。我意识到我的延迟工作需要Heroku附加功能,“Heroku Scheduler Standard”,售价34.50美元。 1)这是否意味着我需要购买,以便我的延迟和cron作业将自动运行?我想知道延迟工作和cron工作是否可以通过使用Heroku日程表完成,那么为什么我们仍然需要javan / when和collectiveidea / delayed_job?我可以在Heroku中使用这些,最好是在免费状态吗?
2) My cron job does not worked in Heroku. How do I run my whenever gem in heroku?
2)我的cron工作在Heroku中不起作用。如何在heroku中运行我的任何宝石?
1 个解决方案
#1
3
There appear to be a couple of thoughts intermixed in your question. I'll do my best to separate them:
在你的问题中似乎有几个想法混杂在一起。我会尽力将它们分开:
a) DelayedJob on Heroku
a)Heroku上的DelayedJob
One way to process jobs queued in DelayedJob (i.e. records sitting in the delayed_jobs table in your database) is to run the following rake task:
处理在DelayedJob中排队的作业(即位于数据库的delayed_jobs表中的记录)的一种方法是运行以下rake任务:
$ rake jobs:work
On heroku, this rake task is commonly run via a 'worker' process.
在heroku上,这个rake任务通常通过“worker”进程运行。
By default for rails apps, your heroku app should already come with a slider for 'workers' (initially set to 0) that will run the rake task above. Merely sliding this to '1' (which will cost you around $34.00 per month) will launch the DelayedJob dequeue process in the background on a dedicated heroku instance, with your codebase, independent of your web dynos.
对于rails应用程序,默认情况下,你的heroku应用程序应该已经为“worker”(最初设置为0)提供了一个滑块,该滑块将运行上面的rake任务。只需将其滑动到'1'(每月花费约34美元)就会在后台的专用heroku实例上启动DelayedJob出列过程,使用您的代码库,独立于您的web dynos。
Note that DelayedJob does NOT require Heroku's "Scheduler" add-on. Also note that heroku charges by hours of processing per month. So, if you slide your 'worker' to '1' for one hour a month, and then slide it back to '0' again when you're done, you will be paying far, far less than the ~$34 charge. There is a way to slide workers on and off programatically too.
请注意,DelayedJob不需要Heroku的“Scheduler”插件。另请注意,heroku按月处理小时数。因此,如果您将“工人”每月滑动到“1”一小时,然后在完成后再将其滑回“0”,您将支付的费用远远低于~34美元的费用。还有一种方法可以以编程方式打开和关闭工作人员。
b) Cron on Heroku
b)Heroku上的Cron
As it stands, managing your own, customized cron file is not possible on heroku or other cloud-based app service providers. Everything is ephemeral, and deployed files cannot be altered by you or your code.
目前,在heroku或其他基于云的应用服务提供商上无法管理您自己的自定义cron文件。一切都是短暂的,部署的文件不能被您或您的代码更改。
Heroku's Scheduler is the appropriate add-on in this case to replace cron. You should be able to set tasks in your heroku scheduler to do what your cron tasks are currently doing.
在这种情况下,Heroku的Scheduler是替换cron的合适附加组件。您应该能够在heroku调度程序中设置任务来执行cron任务当前正在执行的操作。
Last I checked, heroku's scheduler was free (see: https://addons.heroku.com/scheduler), so I'm not sure why you state it is $34.50.
最后我查了一下,heroku的调度程序是免费的(参见:https://addons.heroku.com/scheduler),所以我不确定你说它为34.50美元。
Hope this helps.
希望这可以帮助。
#1
3
There appear to be a couple of thoughts intermixed in your question. I'll do my best to separate them:
在你的问题中似乎有几个想法混杂在一起。我会尽力将它们分开:
a) DelayedJob on Heroku
a)Heroku上的DelayedJob
One way to process jobs queued in DelayedJob (i.e. records sitting in the delayed_jobs table in your database) is to run the following rake task:
处理在DelayedJob中排队的作业(即位于数据库的delayed_jobs表中的记录)的一种方法是运行以下rake任务:
$ rake jobs:work
On heroku, this rake task is commonly run via a 'worker' process.
在heroku上,这个rake任务通常通过“worker”进程运行。
By default for rails apps, your heroku app should already come with a slider for 'workers' (initially set to 0) that will run the rake task above. Merely sliding this to '1' (which will cost you around $34.00 per month) will launch the DelayedJob dequeue process in the background on a dedicated heroku instance, with your codebase, independent of your web dynos.
对于rails应用程序,默认情况下,你的heroku应用程序应该已经为“worker”(最初设置为0)提供了一个滑块,该滑块将运行上面的rake任务。只需将其滑动到'1'(每月花费约34美元)就会在后台的专用heroku实例上启动DelayedJob出列过程,使用您的代码库,独立于您的web dynos。
Note that DelayedJob does NOT require Heroku's "Scheduler" add-on. Also note that heroku charges by hours of processing per month. So, if you slide your 'worker' to '1' for one hour a month, and then slide it back to '0' again when you're done, you will be paying far, far less than the ~$34 charge. There is a way to slide workers on and off programatically too.
请注意,DelayedJob不需要Heroku的“Scheduler”插件。另请注意,heroku按月处理小时数。因此,如果您将“工人”每月滑动到“1”一小时,然后在完成后再将其滑回“0”,您将支付的费用远远低于~34美元的费用。还有一种方法可以以编程方式打开和关闭工作人员。
b) Cron on Heroku
b)Heroku上的Cron
As it stands, managing your own, customized cron file is not possible on heroku or other cloud-based app service providers. Everything is ephemeral, and deployed files cannot be altered by you or your code.
目前,在heroku或其他基于云的应用服务提供商上无法管理您自己的自定义cron文件。一切都是短暂的,部署的文件不能被您或您的代码更改。
Heroku's Scheduler is the appropriate add-on in this case to replace cron. You should be able to set tasks in your heroku scheduler to do what your cron tasks are currently doing.
在这种情况下,Heroku的Scheduler是替换cron的合适附加组件。您应该能够在heroku调度程序中设置任务来执行cron任务当前正在执行的操作。
Last I checked, heroku's scheduler was free (see: https://addons.heroku.com/scheduler), so I'm not sure why you state it is $34.50.
最后我查了一下,heroku的调度程序是免费的(参见:https://addons.heroku.com/scheduler),所以我不确定你说它为34.50美元。
Hope this helps.
希望这可以帮助。