简体   繁体   中英

Spring Boot : Heroku errors after successful deployment

I am struggling with this issue for a couple of days and couldn't find anything on SO and the description of error codes on heroku is to vague for me to figure out anything.I have created a basic app with no db integration, with spring framework, thymeleaf and spring mail.I have no spring security.After successfully deploying it to heroku i try to start the application server and this is what i get in the heroku logs.The app works fine on localhost with no issue.

2020-08-05T08:03:50.144941+00:00 app[web.1]: 2020-08-05 08:03:50.144  INFO 4 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2020-08-05T08:03:50.458342+00:00 app[web.1]: 2020-08-05 08:03:50.458  INFO 4 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2020-08-05T08:03:50.471638+00:00 app[web.1]: 2020-08-05 08:03:50.471  INFO 4 --- [           main] c.e.P.MyWebWebsiteApplication        : Started MyWebWebsiteApplication in 2.688 seconds (JVM running for 3.226)
2020-08-05T08:04:53.993643+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/" host=myweb01.herokuapp.com request_id=0fb69db1-5c01-412e-b01f-451a8a2b7ad8 fwd="86.124.21.129" dyno= connect= service= status=503 bytes= protocol=https
2020-08-05T08:05:16.255402+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 90 seconds of launch
2020-08-05T08:05:16.271979+00:00 heroku[web.1]: Stopping process with SIGKILL
2020-08-05T08:05:16.349020+00:00 heroku[web.1]: Process exited with status 137
2020-08-05T08:05:16.389343+00:00 heroku[web.1]: State changed from starting to crashed
2020-08-05T08:05:16.392175+00:00 heroku[web.1]: State changed from crashed to starting
2020-08-05T08:05:23.662195+00:00 heroku[web.1]: Starting process with command `java $JAVA_OPTS -jar target/MyWebWebsite-0.0.1-SNAPSHOT.jar -Dserver.port=25487 $JAR_OPTS`
2020-08-05T08:05:25.791836+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2020-08-05T08:05:25.796964+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx300m -Xss512k -XX:CICompilerCount=2 -Dfile.encoding=UTF-8 

This is my procfile:

web: java $JAVA_OPTS -jar target/MyWebWebsite-0.0.1-SNAPSHOT.jar -Dserver.port=$PORT $JAR_OPTS

reading the logs and finding this here Tomcat started on port(s): 8080 i suppose could be an issue? i mean tomcat is trying to start on localhost port instead of heroku port?If this is the case how can i fix it? if this is not the case, what could be the issue?

From the docs here error code H20 means

The router will enqueue requests for 75 seconds while waiting for starting processes to reach an “up” state. If after 75 seconds, no web dynos have reached an “up” state, the router logs H20 and serves a standard error page

If your application requires more time to boot, you may use the boot timeout tool to increase the limit. However, in general, slow boot times will make it harder to deploy your application and will make recovery from dyno failures slower, so this should be considered a temporary solution

Try to set boot timeout to 120 seconds - some SpringBoot apps take some time to boot. The request can be done as shown here: https://devcenter.heroku.com/changelog-items/364

Also, the health check process is based on HTTP requests, so be sure that your app is served through normal Web ports (80, 8080, 443).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM