简体   繁体   English

Rails 2 Delayed_job宝石

[英]Rails 2 Delayed_job gem

I am working on rails 2 application where i need to send mail in background job. 我正在Rails 2应用程序上工作,我需要在后台作业中发送邮件。
I have Notifier model and from controller I call a model method to send mail. 我有Notifier模型,并从控制器中调用模型方法来发送邮件。
I call that method Notifier.deliver_method_name(params) before using delayed job and after creating I use it Notifier.delay.deliver_method_name(params) . 我在使用延迟作业之前和创建后使用Notifier.delay.deliver_method_name(params)调用该方法Notifier.deliver_method_name(params)

Now my question arise 现在我的问题出现了

1) Should I need to start the rake jobs:work to send mail in background in development and if yes should I run it every time I start server? 1)我是否需要启动rake作业:在开发中在后台发送邮件的工作;如果是,则每次启动服务器时都应运行它吗?
2) what do I need to do on production should I run rake jobs:work for the first time ? 2)我应该第一次进行耙工作:在工作上需要做什么?
3) Is that right if any error occurs then only there is a entry in delayed job if it is successful then there is no entry in delayed_job table. 3)如果发生任何错误,那么是正确的,如果成功,则延迟作业中只有一个条目,那么delay_job表中就没有条目。

I follow the below link 我点击以下链接

https://github.com/collectiveidea/delayed_job/tree/v2.0 https://github.com/collectiveidea/delayed_job/tree/v2.0

Thanks :) 谢谢 :)

1) Should I need to start the rake jobs:work to send mail in background in development and if yes should I run it every time I start server? 1)我是否需要启动rake作业:在开发中在后台发送邮件的工作;如果是,则每次启动服务器时都应运行它吗?

Yes you have to start rake task separately. 是的,您必须单独启动rake任务。

Workers can be running on any computer, as long as they have access to the database and their clock is in sync. Keep in mind that each worker will check the database at least every 5 seconds.

2) what do I need to do on production should I run rake jobs:work for the first time ? 2)我应该第一次进行耙工作:在工作上需要做什么?

Yes you have to with RAILS_ENV=production script/delayed_job start But I suggest you stop and start this at every deployment to take changes done. 是的,您必须使用RAILS_ENV=production script/delayed_job start但是我建议您在每次部署时停止并启动它,以完成更改。

3) Is that right if any error occurs then only there is a entry in delayed job if it is successful then there is no entry in delayed_job table. 3)如果发生任何错误,那么是正确的,如果成功,则延迟作业中只有一个条目,那么delay_job表中就没有条目。

No it's completely depends on your configuration 不,这完全取决于您的配置

# config/initializers/delayed_job_config.rb
Delayed::Worker.destroy_failed_jobs = false
Delayed::Worker.sleep_delay = 60
Delayed::Worker.max_attempts = 3
Delayed::Worker.max_run_time = 5.minutes

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

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