[英]Spring Boot project hosted on Heroku - Web process failed to bind to $PORT within 90 seconds of launch
I have read many similar questions on stackoverflow and nothing helped me.我在 stackoverflow 上阅读了许多类似的问题,但没有任何帮助。
I have created a spring boot maven backend project and hosted on heroku.我创建了一个 spring 启动 maven 后端项目并托管在 heroku 上。
But, when I try to call from the frontend, it shows an error like this in the browser.但是,当我尝试从前端调用时,它会在浏览器中显示这样的错误。
GET https://hoyamu-springboot-backend.herokuapp.com/fetch/bag 503
When I view the log of heroku it shows an error like this.当我查看 heroku 的日志时,它显示这样的错误。
Web process failed to bind to $PORT within 90 seconds of launch
. Web process failed to bind to $PORT within 90 seconds of launch
。 I did everything and nothing works.我做了一切,但没有任何效果。
My files are as below,我的文件如下,
Heroku Application Log Heroku 应用日志
020-08-08T21:32:21.232432+00:00 heroku[web.1]: State changed from crashed to starting
2020-08-08T21:32:25.103258+00:00 heroku[web.1]: Starting process with command `java -Dserver.port=48348 $JAVA_OPTS -jar target/hoyamu-0.0.1-SNAPSHOT.jar`
2020-08-08T21:32:27.226023+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2020-08-08T21:32:27.230034+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx300m -Xss512k -XX:CICompilerCount=2 -Dfile.encoding=UTF-8
2020-08-08T21:32:28.818160+00:00 app[web.1]:
2020-08-08T21:32:28.818210+00:00 app[web.1]: . ____ _ __ _ _
2020-08-08T21:32:28.818211+00:00 app[web.1]: /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
2020-08-08T21:32:28.818214+00:00 app[web.1]: ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
2020-08-08T21:32:28.818294+00:00 app[web.1]: \\/ ___)| |_)| | | | | || (_| | ) ) ) )
2020-08-08T21:32:28.818323+00:00 app[web.1]: ' |____| .__|_| |_|_| |_\__, | / / / /
2020-08-08T21:32:28.818414+00:00 app[web.1]: =========|_|==============|___/=/_/_/_/
2020-08-08T21:32:28.819695+00:00 app[web.1]: :: Spring Boot :: (v2.2.6.RELEASE)
2020-08-08T21:32:28.819727+00:00 app[web.1]:
2020-08-08T21:32:29.047717+00:00 app[web.1]: 2020-08-08 21:32:29.044 INFO 4 --- [ main] com.udith.hoyamu.HoyamuApplication : Starting HoyamuApplication v0.0.1-SNAPSHOT on 50382c68-eaab-4b3c-ac0c-a881a18e4a0b with PID 4 (/app/target/hoyamu-0.0.1-SNAPSHOT.jar started by u8138 in /app)
2020-08-08T21:32:29.048863+00:00 app[web.1]: 2020-08-08 21:32:29.048 INFO 4 --- [ main] com.udith.hoyamu.HoyamuApplication : No active profile set, falling back to default profiles: default
2020-08-08T21:32:30.083462+00:00 app[web.1]: 2020-08-08 21:32:30.081 INFO 4 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2020-08-08T21:32:30.224960+00:00 app[web.1]: 2020-08-08 21:32:30.224 INFO 4 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 130ms. Found 18 JPA repository interfaces.
2020-08-08T21:32:31.310818+00:00 app[web.1]: 2020-08-08 21:32:31.310 INFO 4 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 48348 (http)
2020-08-08T21:32:31.327532+00:00 app[web.1]: 2020-08-08 21:32:31.327 INFO 4 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-08-08T21:32:31.327720+00:00 app[web.1]: 2020-08-08 21:32:31.327 INFO 4 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.33]
2020-08-08T21:32:31.405048+00:00 app[web.1]: 2020-08-08 21:32:31.404 INFO 4 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-08-08T21:32:31.405289+00:00 app[web.1]: 2020-08-08 21:32:31.405 INFO 4 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2272 ms
2020-08-08T21:32:31.669531+00:00 app[web.1]: 2020-08-08 21:32:31.669 INFO 4 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2020-08-08T21:32:31.931057+00:00 app[web.1]: 2020-08-08 21:32:31.930 INFO 4 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.12.Final
2020-08-08T21:32:32.109028+00:00 app[web.1]: 2020-08-08 21:32:32.108 INFO 4 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2020-08-08T21:32:32.249430+00:00 app[web.1]: 2020-08-08 21:32:32.249 INFO 4 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2020-08-08T21:32:33.786599+00:00 app[web.1]: 2020-08-08 21:32:33.786 INFO 4 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2020-08-08T21:32:33.850851+00:00 app[web.1]: 2020-08-08 21:32:33.850 INFO 4 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL8Dialect
2020-08-08T21:33:55.347291+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 90 seconds of launch
2020-08-08T21:33:55.368253+00:00 heroku[web.1]: Stopping process with SIGKILL
2020-08-08T21:33:55.465503+00:00 heroku[web.1]: Process exited with status 137
2020-08-08T21:33:55.499546+00:00 heroku[web.1]: State changed from starting to crashed
2020-08-08T21:50:58.187914+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/fetch/bag" host=hoyamu-springboot-backend.herokuapp.com request_id=db721f39-aab3-4a3f-82e9-6495dc6bc7a8 fwd="112.135.40.125" dyno= connect= service= status=503 bytes= protocol=https
Procfile档案
web: java -Dserver.port=$PORT $JAVA_OPTS -jar target/hoyamu-0.0.1-SNAPSHOT.jar
application.properties应用程序属性
hibernate.dialect=org.hibernate.dialect.MySQL57Dialect
spring.datasource.url=jdbc:mysql://remotemysql.com:3306/MMgqawaw
spring.datasource.username=username
spring.datasource.password=password
spring.jpa.hibernate.ddl-auto=update
spring.jpa.hibernate.show_sql=true
spring.jpa.hibernate.format_sql=true
spring.jpa.show-sql=true
```
What should I do?
After several small surveys, I could find the solution for my issue.经过几次小型调查,我可以找到解决问题的方法。
The error Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 90 seconds of launch
can happen due to two reasons.错误
Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 90 seconds of launch
可能由于两个原因而发生。
(replace <BUILT_APP_NAME_HERE> with your app name after deployed) (部署后将 <BUILT_APP_NAME_HERE> 替换为您的应用名称)
web: java $JAVA_OPTS -jar -Dserver.port=$PORT target/<BUILT_APP_NAME_HERE>.jar
[or] [或者]
When giving *, you don't need to specify the name给*的时候不需要指定名字
web: java $JAVA_OPTS -jar -Dserver.port=$PORT target/*.jar
[or] [或者]
web: java $JAVA_OPTS -jar -Dspring.profiles.active=production target/<BUILT_APP_NAME_HERE>.jar --port $PORT
The solution for this is, we have to increase the boot time of the app.解决方案是,我们必须增加应用程序的启动时间。 you can do this by following this link.
您可以按照此链接执行此操作。 ( Sometimes this link gives errors, then try with another browser or with your mobile phone's browser)
(这个链接有时候会报错,换个浏览器或者手机浏览器试试)
https://tools.heroku.support/limits/boot_timeout https://tools.heroku.support/limits/boot_timeout
However, it is not recommended to increase the boot time more 120secs.但是,不建议将启动时间增加 120 秒以上。
But, in real case, you should find the solution why it takes much time to make the db connection.但是,在实际情况下,您应该找到为什么需要花费大量时间来建立数据库连接的解决方案。
i was able to run my spring mvc app with this Procfile content:我能够使用此 Procfile 内容运行我的 spring mvc 应用程序:
web: java $JAVA_OPTS -jar target/dependency/webapp-runner.jar --port $PORT target/*.war web: java $JAVA_OPTS -jar 目标/依赖/webapp-runner.jar --port $PORT 目标/*.war
this is the deployed app: http://duckingrace.herokuapp.com/web/canvasv1这是部署的应用程序: http://duckingrace.herokuapp.com/web/canvasv1
this is the source code: https://github.com/fajaralmu/java-websocket1这是源代码: https://github.com/fajaralmu/java-websocket1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.