Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
python脚本工作正常,但heroku崩溃了_Python_Heroku_Beautifulsoup_Sendgrid - Fatal编程技术网

python脚本工作正常,但heroku崩溃了

python脚本工作正常,但heroku崩溃了,python,heroku,beautifulsoup,sendgrid,Python,Heroku,Beautifulsoup,Sendgrid,我正在为我爸爸开发一个应用程序,它可以删除乐透结果(beautifulsoup)并通过电子邮件发送(sendgrid)。我使用heroku按计划运行脚本。如果我运行它,它会工作得很好。电子邮件将被发送,但进程将崩溃,这会因为错误而重新启动它们。崩溃并没有那么严重,因为脚本将完成它的工作,但问题是dyno的重新启动,这导致许多电子邮件被发送。你可以在我的回购协议中找到脚本 我猜是BeautifulSoup和/或sendgrid的异步性。你知道如何在heroku中获得更好的日志信息吗?如果我注释掉实

我正在为我爸爸开发一个应用程序,它可以删除乐透结果(beautifulsoup)并通过电子邮件发送(sendgrid)。我使用heroku按计划运行脚本。如果我运行它,它会工作得很好。电子邮件将被发送,但进程将崩溃,这会因为错误而重新启动它们。崩溃并没有那么严重,因为脚本将完成它的工作,但问题是dyno的重新启动,这导致许多电子邮件被发送。你可以在我的回购协议中找到脚本

我猜是BeautifulSoup和/或sendgrid的异步性。你知道如何在heroku中获得更好的日志信息吗?如果我注释掉实际的电子邮件发送部分,并在十分钟内启动调度程序,那么它可以工作,但工作人员不能

我的proc文件如下所示:

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 ...
为什么工人要跑?如果你需要进一步的信息,现在就告诉我。谢谢你的帮助

解决方案:我已认识到我可以停用该工作人员
让调度程序运行,但问题仍然是,为什么worker会崩溃。

worker用于web服务/服务器而不是CLI应用这就是它崩溃的原因,您会收到许多电子邮件,因为如果崩溃,它会自动重新启动。不需要工作程序。您可以删除
Procfile
,或者在
睡眠时使用
创建实际调度程序的虚拟服务器