[英]Why does this rake task appear to not be running in Heroku?
因此,我嘗試運行rake任務:
heroku run:detached rake some_task --app myproductionapp
Heroku告訴我使用heroku logs -p run.8334 -a myproductionapp
查看日志
當我在控制台中運行該日志記錄命令時,沒有任何顯示。 這意味着任務沒有運行(或者是?)。 在專業的dyno計划上,我在P_L級別有1個web,在1x級別有1個時鍾,在P_L級別有1個sidekiq dyno運行。 我需要設置工人測功機嗎?
要測試是否很明顯:
因此,當我使用Mailinator進行測試並調用一次我用來向用戶發送電子郵件的函數時,會收到如下所示的實際“已處理”消息,並且在Mailinator中看到了該電子郵件。
MyEmailer#send_this_message: processed outbound mail in 407.3ms
=> #<ActionMailer::Base::NullMail:0x007gg91b5700a0>
當我嘗試生產時,沒有得到處理后的消息響應,僅得到如下的ActionMailer :: Base :: NullMail。
=> #<ActionMailer::Base::NullMail:0x007gg91b5700a0>
登台郵件設置:
config.action_mailer.default_url_options = { :host => ENV['STAGING_HOST'] }
# ActionMailer Config
# Setup for production - deliveries, no errors raised
config.action_mailer.delivery_method = :smtp
#config.action_mailer.perform_deliveries = true
#config.action_mailer.raise_delivery_errors = false
#config.action_mailer.default :charset => "utf-8"
config.action_mailer.smtp_settings = {
:address => "smtp.mandrillapp.com",
:port => 587,
:user_name => ENV['MANDRILLUSER'],
:password => ENV['MANDRILL_KEY'],
:domain => 'heroku.com'
用於生產的郵件設置:
# ActionMailer Config
# Setup for production - deliveries, no errors raised
config.action_mailer.delivery_method = :smtp
#config.action_mailer.perform_deliveries = true
#config.action_mailer.raise_delivery_errors = false
#config.action_mailer.default :charset => "utf-8"
config.action_mailer.smtp_settings = {
:address => "smtp.mandrillapp.com",
:port => 587,
:user_name => ENV['MANDRILLUSER'],
:password => ENV['MANDRILL_KEY'],
:domain => 'productionapp.com',
:enable_startls_auto => true
}
好吧,這很奇怪,但是這可能是由於您的任務中的錯誤而發生的,請檢查整個日志heroku logs -a myproductionapp
為了回答您的問題,您不需要任何工作人員dyno,這些工作人員是用於后台作業的,如果您手動運行任務,則不需要工作人員,例如,如果安裝了“ heroku Scheduler”插件,則可以對cron進行編程無需工人就可以在任何時間運行任務。
多虧了您添加到問題中的新細節,在生產配置中,您在階段中也缺少主機:
config.action_mailer.default_url_options = { :host => ENV['STAGING_HOST'] }
好了,您需要在此處添加生產主機,可以手動添加:
config.action_mailer.default_url_options = { :host => 'http://yourproductionapp.com' }
或使用環境變量:
config.action_mailer.default_url_options = { :host => ENV['PRODUCTION_HOST'] }
確保您的環境變量在heroku生產應用程序中具有正確的值。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.