Heroku 应用程序在成功启动后崩溃
Heroku app crashes after successfully started
当我部署我的 spring 应用程序时,它使用 heroku postgres db 进行初始化并且一切正常,但随后状态变为 "crashed"。如果我 运行 它与 heroku local
一切正常。
日志:
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
所以。根据 heroku 政策,您的应用程序将在随机端口启动,目前可以免费使用。您的 Procfile
应该如下所示(对于 spring 启动)
web: java -jar target/jarname.jar --server.port=$PORT
您也可以将其用作 application.properties
属性。
感谢 Malax 的帮助。
当我部署我的 spring 应用程序时,它使用 heroku postgres db 进行初始化并且一切正常,但随后状态变为 "crashed"。如果我 运行 它与 heroku local
一切正常。
日志:
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
所以。根据 heroku 政策,您的应用程序将在随机端口启动,目前可以免费使用。您的 Procfile
应该如下所示(对于 spring 启动)
web: java -jar target/jarname.jar --server.port=$PORT
您也可以将其用作 application.properties
属性。
感谢 Malax 的帮助。