[英]Why does this rake task appear to not be running in Heroku?
So I tried running a rake task: 因此,我尝试运行rake任务:
heroku run:detached rake some_task --app myproductionapp
Heroku told me to view the logs with heroku logs -p run.8334 -a myproductionapp
Heroku告诉我使用
heroku logs -p run.8334 -a myproductionapp
查看日志
When I run that logging command in my console, nothing appears. 当我在控制台中运行该日志记录命令时,没有任何显示。 This means the task didn't run (or does it?).
这意味着任务没有运行(或者是?)。 On the professional dyno plan, I have 1 web at P_L level, 1 clock at 1x level, and 1 sidekiq dyno at P_L level running.
在专业的dyno计划上,我在P_L级别有1个web,在1x级别有1个时钟,在P_L级别有1个sidekiq dyno运行。 Do I need to setup a worker dyno?
我需要设置工人测功机吗?
To test out if it's something obvious: 要测试是否很明显:
So when I do a test with Mailinator and call the function I'm using to email a user one time, I get an actual "processed" message such as below and I see the email message in Mailinator.: 因此,当我使用Mailinator进行测试并调用一次我用来向用户发送电子邮件的函数时,会收到如下所示的实际“已处理”消息,并且在Mailinator中看到了该电子邮件。
MyEmailer#send_this_message: processed outbound mail in 407.3ms
=> #<ActionMailer::Base::NullMail:0x007gg91b5700a0>
When I try on production I don't get the processed message response, I only get the ActionMailer::Base::NullMail as below. 当我尝试生产时,没有得到处理后的消息响应,仅得到如下的ActionMailer :: Base :: NullMail。
=> #<ActionMailer::Base::NullMail:0x007gg91b5700a0>
Mailing setup for staging: 登台邮件设置:
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'
Mailing setup for production: 用于生产的邮件设置:
# 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
}
Well this is very weird, but this may be happening due to an error in your task, check the whole logs heroku logs -a myproductionapp
好吧,这很奇怪,但是这可能是由于您的任务中的错误而发生的,请检查整个日志
heroku logs -a myproductionapp
For answer your question, you do not need any worker dyno, those are for background jobs, if you run the task manually then you do not need a worker, for example if you install "heroku scheduler" addon, then you can program your cron to run the task every amount of time without the need of a worker. 为了回答您的问题,您不需要任何工作人员dyno,这些工作人员是用于后台作业的,如果您手动运行任务,则不需要工作人员,例如,如果安装了“ heroku Scheduler”插件,则可以对cron进行编程无需工人就可以在任何时间运行任务。
Thanks to the new details you added to your question, well in your production configuration you are missing the host, in your staging you have: 多亏了您添加到问题中的新细节,在生产配置中,您在阶段中也缺少主机:
config.action_mailer.default_url_options = { :host => ENV['STAGING_HOST'] }
Well you need to add here your production host, you can add it manually: 好了,您需要在此处添加生产主机,可以手动添加:
config.action_mailer.default_url_options = { :host => 'http://yourproductionapp.com' }
or using an environment variable: 或使用环境变量:
config.action_mailer.default_url_options = { :host => ENV['PRODUCTION_HOST'] }
make sure your environment variable has the correct value in your heroku production app. 确保您的环境变量在heroku生产应用程序中具有正确的值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.