简体   繁体   English

Heroku 应用程序成功启动后崩溃

[英]Heroku app crashes after successfully started

When I deploy my spring application it initializes with heroku postgres db and everything works fine, but then status changes to "crashed".当我部署我的 spring 应用程序时,它使用 heroku postgres db 进行初始化,一切正常,但随后状态更改为“崩溃”。 If I run it with heroku local everything works fine.如果我使用heroku local运行它,一切正常。 logs:日志:

2020-04-01T23:14:56.352610+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2020-04-01T23:14:56.356959+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -XX:+UseContainerSupport -Xmx300m -Xss512k -XX:CICompilerCount=2 -Dfile.encoding=UTF-8
2020-04-01T23:14:57.000000+00:00 app[api]: Build succeeded
2020-04-01T23:14:58.172994+00:00 app[web.1]: LOGBACK: No context given for c.q.l.core.rolling.SizeAndTimeBasedRollingPolicy@1021436681
2020-04-01T23:14:58.347661+00:00 app[web.1]:
2020-04-01T23:14:58.347672+00:00 app[web.1]: .   ____          _            __ _ _
2020-04-01T23:14:58.347758+00:00 app[web.1]: /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
2020-04-01T23:14:58.347824+00:00 app[web.1]: ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
2020-04-01T23:14:58.347891+00:00 app[web.1]: \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
2020-04-01T23:14:58.347959+00:00 app[web.1]: '  |____| .__|_| |_|_| |_\__, | / / / /
2020-04-01T23:14:58.348042+00:00 app[web.1]: =========|_|==============|___/=/_/_/_/
2020-04-01T23:14:58.349377+00:00 app[web.1]: :: Spring Boot ::        (v2.2.5.RELEASE)
2020-04-01T23:14:58.349417+00:00 app[web.1]:
2020-04-01T23:14:58.646256+00:00 app[web.1]: 2020-04-01 23:14:58.641  INFO 4 --- [           main] c.s.s.ServerHospitalApplication          : Starting ServerHospitalApplication v0.0.1-SNAPSHOT on ee8bd841-dcb7-4af4-90f2-fb5330b4b247 with PID 4 (/app/target/server-hospital-0.0.1-SNAPSHOT.jar started by u45481 in /app)
2020-04-01T23:14:58.647797+00:00 app[web.1]: 2020-04-01 23:14:58.647  INFO 4 --- [           main] c.s.s.ServerHospitalApplication          : No active profile set, falling back to default profiles: default
2020-04-01T23:14:59.704318+00:00 app[web.1]: 2020-04-01 23:14:59.702  INFO 4 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2020-04-01T23:14:59.796551+00:00 app[web.1]: 2020-04-01 23:14:59.796  INFO 4 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 79ms. Found 2 JPA repository interfaces.
2020-04-01T23:15:00.931272+00:00 app[web.1]: 2020-04-01 23:15:00.931  INFO 4 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2020-04-01T23:15:00.946566+00:00 app[web.1]: 2020-04-01 23:15:00.946  INFO 4 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2020-04-01T23:15:00.946955+00:00 app[web.1]: 2020-04-01 23:15:00.946  INFO 4 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.31]
2020-04-01T23:15:01.012734+00:00 app[web.1]: 2020-04-01 23:15:01.012  INFO 4 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2020-04-01T23:15:01.013067+00:00 app[web.1]: 2020-04-01 23:15:01.012  INFO 4 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 2288 ms
2020-04-01T23:15:01.245799+00:00 app[web.1]: 2020-04-01 23:15:01.245  INFO 4 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
2020-04-01T23:15:01.339150+00:00 app[web.1]: 2020-04-01 23:15:01.338  INFO 4 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 5.4.12.Final
2020-04-01T23:15:01.518879+00:00 app[web.1]: 2020-04-01 23:15:01.518  INFO 4 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2020-04-01T23:15:01.652931+00:00 app[web.1]: 2020-04-01 23:15:01.652  INFO 4 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2020-04-01T23:15:02.045903+00:00 app[web.1]: 2020-04-01 23:15:02.045  INFO 4 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2020-04-01T23:15:02.080020+00:00 app[web.1]: 2020-04-01 23:15:02.079  INFO 4 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQL10Dialect
2020-04-01T23:15:04.111351+00:00 app[web.1]: 2020-04-01 23:15:04.111  INFO 4 --- [           main] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2020-04-01T23:15:04.121608+00:00 app[web.1]: 2020-04-01 23:15:04.121  INFO 4 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-04-01T23:15:04.702613+00:00 app[web.1]: 2020-04-01 23:15:04.702  WARN 4 --- [           main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2020-04-01T23:15:04.947395+00:00 app[web.1]: 2020-04-01 23:15:04.947  INFO 4 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2020-04-01T23:15:05.444803+00:00 app[web.1]: 2020-04-01 23:15:05.444  INFO 4 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2020-04-01T23:15:05.448231+00:00 app[web.1]: 2020-04-01 23:15:05.448  INFO 4 --- [           main] c.s.s.ServerHospitalApplication          : Started ServerHospitalApplication in 8.023 seconds (JVM running for 9.091)
2020-04-01T23:16:25.088442+00:00 heroku[web.1]: State changed from starting to crashed
2020-04-01T23:16:25.713713+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=fx-server.herokuapp.com request_id=16a54f69-760a-4fa1-9813-93f4c5846440 fwd="93.85.72.168" dyno= connect= service= status=503 bytes= protocol=https
2020-04-01T23:16:25.935733+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=fx-server.herokuapp.com request_id=e4b37c4b-a4bf-4411-803e-c9e15be13287 fwd="93.85.72.168" dyno= connect= service= status=503 bytes= protocol=https

So.所以。 According to the heroku policy, your app will be started at the random port, that currently is free for usage.根据 heroku 政策,您的应用程序将在当前免费使用的随机端口上启动。 Your Procfile should look like this (for spring boot)您的Procfile应如下所示(用于春季启动)

web: java -jar target/jarname.jar --server.port=$PORT

You also can use this as application.properties property.您也可以将其用作application.properties属性。

Thanks to Malax for help.感谢马拉克斯的帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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