有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

无法为Heroku上的discord bot设置java端口

我已经使用javacord库编写了一个discord机器人,它工作得非常好,因为如果我用IntelliJ idea运行该程序,该机器人就可以在线使用discord(我可以使用它)

当我将bot上传到heroku时,我可以使用它几分钟,然后会出现以下错误:

2019-02-04T22:21:01.000000+00:00 app[api]: Build started by user aa@aa.com

2019-02-04T22:21:15.414268+00:00 heroku[web.1]: State changed from crashed to starting

2019-02-04T22:21:19.806474+00:00 heroku[web.1]: Starting process with command `java $JAVA_OPTS -jar warbot.jar -server.port=22270`

2019-02-04T22:21:14.200586+00:00 app[api]: Deploy dc88e3ab by user aa@aa.com

2019-02-04T22:21:22.813747+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.

2019-02-04T22:21:22.825641+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx300m -Xss512k -XX:CICompilerCount=2 -Dfile.encoding=UTF-8 

2019-02-04T22:21:23.528694+00:00 app[web.1]: 2019-02-04 22:21:23.469+0000 INFO org.javacord.core.util.logging.ExceptionLoggerDelegateImpl No Log4j2 compatible logger was found. Using default Javacord implementation!

2019-02-04T22:21:27.268649+00:00 app[web.1]: The bot has started

2019-02-04T22:21:14.200586+00:00 app[api]: Release v25 created by user aa@aa.com

2019-02-04T22:21:24.000000+00:00 app[api]: Build succeeded

2019-02-04T22:22:50.697048+00:00 heroku[web.1]: State changed from starting to crashed

2019-02-04T22:22:50.530237+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 90 seconds of launch

2019-02-04T22:22:50.530363+00:00 heroku[web.1]: Stopping process with SIGKILL

2019-02-04T22:22:50.678651+00:00 heroku[web.1]: Process exited with status 137

基本上,在几个小时后,机器人崩溃了。我怎样才能解决这个问题


很多在线答案都提到了Spring框架,但我没有使用它!而涉及-Dspring.server.port=$PORT的解决方案不起作用。我的proc文件中有:

web: java $JAVA_OPTS -jar warbot.jar -server.port=$PORT

其中warbot.jar是与Procfile(在根目录中)位于同一位置的jar。我怎样才能解决这个问题?上面的行似乎不足以设置端口

我基本上必须设置端口,以便heroku不会抱怨,我的机器人可以保持在线


共 (0) 个答案