我正在为我爸爸开发一个应用程序,它可以将乐透结果(beautifulsoup)通过电子邮件(sendgrid)发送出去。我使用heroku按计划运行脚本github repo。如果我运行它,它会工作得很好。电子邮件将被发送,但由于dyno restart policy,进程崩溃,重新启动它们。崩溃并不是那么糟糕,因为脚本可以完成它的工作,但问题是dyno的重新启动,这会导致发送许多电子邮件。你可以在我的报告里找到剧本
我猜是BeautifulSoup和/或sendgrid的异步性。你知道如何在heroku中获得更好的日志信息吗?如果我注释掉了实际的电子邮件发送部分,并在10分钟内启动调度程序,那么它可以工作,但工人不能
我的文件看起来像:
worker: python lotto_mailer.py
这是服务器日志
Nov 19 05:56:36 lotto-mailer heroku/scheduler.2285: Starting process with command `if [ "$(date +%u)" = 1 ]; then python lotto_mailer.py; fi`
Nov 19 05:56:37 lotto-mailer heroku/scheduler.2285: State changed from starting to up
Nov 19 05:56:40 lotto-mailer heroku/scheduler.2285: State changed from up to complete
Nov 19 05:56:40 lotto-mailer heroku/scheduler.2285: Process exited with status 0
Nov 19 05:56:41 lotto-mailer app/scheduler.2285: Ziehung vom Samstag, 17.11.2018
Nov 19 05:56:41 lotto-mailer app/scheduler.2285: Gewinnzahlen: [3, 6, 18, 31, 39, 40] SZ: 5
... App OUTPUT ...
Nov 19 05:56:41 lotto-mailer app/scheduler.2285: UTC Hour: 13
不要被调度程序运行的命令分心。只是在星期一才运行。似乎只有工作人员崩溃,而不是调度程序崩溃
Nov 19 06:04:24 lotto-mailer heroku/worker.1: State changed from crashed to starting
Nov 19 06:04:29 lotto-mailer heroku/worker.1: Starting process with command `python lotto_mailer.py`
Nov 19 06:04:29 lotto-mailer heroku/worker.1: State changed from starting to up
Nov 19 06:04:29 lotto-mailer heroku/worker.1: State changed from crashed to starting
Nov 19 06:04:32 lotto-mailer heroku/worker.1: State changed from up to crashed
Nov 19 06:04:33 lotto-mailer heroku/worker.1: Process exited with status 0
Nov 19 06:04:33 lotto-mailer app/worker.1: Ziehung vom Samstag, 17.11.2018
Nov 19 06:04:33 lotto-mailer app/worker.1: Gewinnzahlen: [3, 6, 18, 31, 39, 40] SZ: 5
... APP OUTPUT ...
为什么工人要跑?如果你需要进一步的信息,现在就告诉我。谢谢你的帮助
解决方案:我已经认识到我可以停用工作进程 here 让调度程序运行,但问题仍然是,为什么工人会崩溃
worker是用于web服务/服务器而不是CLI应用程序这就是为什么它会崩溃,并且您会收到许多电子邮件,因为如果崩溃,它将自动重新启动。不需要worker,您可以删除
Procfile
,也可以使用while
和sleep
创建实际调度程序的虚拟服务器相关问题 更多 >
编程相关推荐