英文:
heroku[web.1]: State changed from starting to crashed
问题
我有一个在Heroku上运行Discord机器人的Gradle程序。该机器人处理所有可能的异常,并且在我的个人电脑上运行得很好。我切换到了Heroku,因为我不希望在我需要重新启动个人电脑或其他原因时机器人下线。
根据应用程序的日志,该程序没有错误。部署后的几分钟内,日志只是简单地显示“状态从启动更改为崩溃”。是否有办法获取有关应用程序崩溃原因的更多细节?我有90%的把握认为我的应用程序不会自行崩溃,因为它在我的个人电脑上运行了相当长的时间而没有任何问题。
偶尔,日志会显示“状态从崩溃更改为启动”,并且程序将会重新运行,就好像我重新部署了应用程序一样,但实际上我并没有这么做。Heroku是否可能以某种方式循环运行应用程序?
无论如何,该应用程序仅在大约两到五分钟内运行,从未更长时间地运行,在日志中也没有错误。非常感谢您的任何帮助!
英文:
I have a Gradle program that runs a Discord bot on Heroku. The bot handles all possible exceptions, and it runs beautifully on my PC. I switched to Heroku, because I do not want the bot to go offline when I need to restart my PC or for other reasons.
According to the app's logs, the program has no errors. A few minutes after deployment, the logs simply say "State changed from starting to crashed." Is there a way to get more details about why the app crashed? I'm 90% convinced my app does not crash on its own, as it has been running on my PC for quite some time with no problems.
Every once in a while, the logs will say "State changed from crashed to starting" and the program will rerun as if I redeployed the app, but I did not. Could Heroku be cycling the app in some way?
Either way, the app only runs for around two to five minutes, never longer, with no errors in the logs. Any help is appreciated!
答案1
得分: 2
代码部分不要翻译,只返回翻译好的内容:
没有为我的机器人设置前端界面,因此在 Procfile 中不需要使用 web:,就像我在入门教程中没有完全理解的那样。相反,对于仅具有后端进程的应用程序,请使用 worker:。此外,在 CLI 中,通过以下方式验证是否没有 web 进程:
heroku ps:scale --app <app-name> web=0
然后设置一个后端进程:
heroku ps:scale --app <app-name> worker=1
或者根据需要设置更多。此外,如果没有前端界面,请避免在 Procfile 中使用附加到端口的标志。
要了解更多关于如果配置不正确会导致什么问题,请访问 https://devcenter.heroku.com/articles/dynos#dyno-configurations
感谢 VxJasonxV 的帮助。
英文:
With no front end for my bot, it is not necessary to use web: in the Procfile, as I did not fully understand from the Getting Started tutorial. Instead use worker: for apps with only back end processes. Also, from the CLI, verify that there are no web processes with
heroku ps:scale --app <app-name> web=0
and set up a back end process with
heroku ps:scale --app <app-name> worker=1
or more if necessary. Also, avoid flags for attaching to a port in the Procfile if you have no front end.
To learn more about why this causes issues if not right, visit https://devcenter.heroku.com/articles/dynos#dyno-configurations
Shoutout to VxJasonxV for the help.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论