繁体   English   中英

为什么此rake任务似乎不在Heroku中运行?

[英]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.

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