简体   繁体   English

为什么“延迟工作”不能与我的ActionMailer生产设置一起使用?

[英]Why doesn't Delayed Jobs work with my ActionMailer production setup?

I am working on a Ruby (1.8.6) on Rails (2.3.5) application in which I am currently using Gmail to deliver email messages. 我正在研究Rails(2.3.5)上的Ruby(1.8.6)应用程序,目前正在其中使用Gmail传递电子邮件。 I want to switch to sending the messages with Delayed Jobs. 我想切换到“延迟作业”发送消息。

I have delayed jobs sending messages on my development environment but when I deploy to my production server and try the messages get rejected and an error shows up in my delayed_jobs table: 530 5.7.0 Must issue a STARTTLS command first. i25sm12946175anh.17. 我在我的开发环境上延迟了发送消息的作业,但是当我部署到生产服务器并尝试拒绝消息并在我的delay_jobs表中显示错误时: 530 5.7.0 Must issue a STARTTLS command first. i25sm12946175anh.17. 530 5.7.0 Must issue a STARTTLS command first. i25sm12946175anh.17. I've seen this error before (when I don't have TLS enabled in my config). 之前(当我的配置中未启用TLS时),我已经看到此错误。 But it was working before I started using delayed_jobs. 但是在我开始使用delay_jobs之前,它一直在工作。 Here is my mail config: 这是我的邮件配置:

ActionMailer::Base.smtp_settings = {
  :enable_starttls_auto => true,
  :address => 'smtp.gmail.com',
  :port => 587,
  :domain => 'example.com',
  :authentication => :plain,
  :user_name => 'user@example.com',
  :password => 'password'
}

Any help with this issue is greatly appreciated. 非常感谢您对此问题的任何帮助。

Update : The application is actually running on REE ruby 1.8.7. 更新 :该应用程序实际上在REE ruby​​ 1.8.7上运行。 So maybe delayed jobs is somehow using the regular ruby interpreter installed on the server (1.8.6). 因此,也许延迟的工作是以某种方式使用服务器上安装的常规ruby解释器(1.8.6)。 But, how do I get delayed jobs to use my REE install? 但是,如何获得延迟的工作才能使用REE安装? And how do I tell what things are using what version of Ruby. 以及如何知道什么东西正在使用哪个版本的Ruby。

Normally you would use :enable_starttls_auto as you wrote, but that only works for ruby >= 1.8.7 and ruby >= 1.9. 通常,您在编写时会使用:enable_starttls_auto ,但这仅适用于ruby> = 1.8.7和ruby> = 1.9。

So you need to use the solution as stated here : define a file smtp_tls.rb which you place in your initializers folder. 因此,您需要使用此处所述的解决方案:定义一个文件smtp_tls.rb ,将其放置在初始化程序文件夹中。

But, how do I get delayed jobs to use my REE install? 但是,如何获得延迟的工作才能使用REE安装? And how do I tell what things are using what version of Ruby. 以及如何知道什么东西正在使用哪个版本的Ruby。

The script/delayed_job command uses the system Ruby. script/delayed_job命令使用系统Ruby。 So " which ruby " should point to the REE installation. 因此,“ which ruby ”应指向REE安装。 If not, you can force it by using the Ruby executable. 如果没有,您可以使用Ruby可执行文件强制执行。 Lets say, your REE is installed at /opt/ruby-enterprise-1.8.7-2010.01 . 可以说,您的REE安装在/opt/ruby-enterprise-1.8.7-2010.01 Then: 然后:

$ RAILS_ENV=production /opt/ruby-enterprise-1.8.7-2010.01/bin/ruby script/delayed_job -n 2 start

Or if you use the rake command to start, like: 或者,如果您使用rake命令来启动,例如:

$ rake jobs:work -t RAILS_ENV=production

Then which rake should point to your REE installation. 然后which rake应该指向您的REE安装。 If its not, then you can make it use REE by: 如果不是,则可以通过以下方式使它使用REE:

RAILS_ENV=production /opt/ruby-enterprise-1.8.7-2010.01/bin/rake jobs:work -t

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

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