tomcat - Heroku 上的 Spring Boot 应用程序

标签 tomcat spring-boot heroku

我正在尝试在 Heroku 上部署 spring boot 应用程序,它在部署应用程序后抛出以下错误。

2018-04-13T16:47:42.573257Z system[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2018-04-13T16:47:42.573323Z system[web.1]: Stopping process with SIGTERM
2018-04-13T16:47:42.5788Z app[web.1]: 2018-04-13 16:47:42.577  INFO 26 --- [       Thread-3] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@75a1cd57: startup date [Fri Apr 13 16:46:43 UTC 2018]; root of context hierarchy
2018-04-13T16:47:42.585423Z app[web.1]: 2018-04-13 16:47:42.585  INFO 26 --- [       Thread-3] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown
2018-04-13T16:47:43.574239Z system[web.1]: Process exited (exit status 143)
2018-04-13T16:47:43.596277+00:00 system[web.1]: State changed from starting to crashed

下面的日志告诉我们在 proc 文件中手动提供的端口 8085 上部署成功

2018-04-13T16:46:47.276958Z app[web.1]: 2018-04-13 16:46:47.276  INFO 26 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8085 (http)

过程文件:

web: java -Dserver.port=8085 -jar target/app.war

感谢任何帮助

编辑:

@jusermar10 感谢您的回复。是的,我正在尝试设置静态端口并且不想使用@user3314492 指出的由 heroku 分配的端口。我知道动态端口方法工作正常。我们面临的问题是我们正在尝试使用 nginx 代理通过 https://github.com/theoephraim/nginx-buildpack 的 builpack 进行缓存。 .如果我们使用动态端口,nginx 配置文件也会使用它,这就是它抛出以下错误的原因

2018-04-14T17:09:24.427513Z app[web.1]: buildpack=nginx at=nginx-start
2018-04-14T17:09:24.440105Z app[web.1]: nginx: [emerg] bind() to 0.0.0.0:10949 failed (98: Address already in use)
2018-04-14T17:09:24.440137Z app[web.1]: 2018/04/14 17:09:24 [emerg] 159#0: bind() to 0.0.0.0:10949 failed (98: Address already in use)
2018-04-14T17:09:24.940239Z app[web.1]: nginx: [emerg] bind() to 0.0.0.0:10949 failed (98: Address already in use)
2018-04-14T17:09:24.940285Z app[web.1]: 2018/04/14 17:09:24 [emerg] 159#0: bind() to 0.0.0.0:10949 failed (98: Address already in use)
2018-04-14T17:09:25.440529Z app[web.1]: nginx: [emerg] bind() to 0.0.0.0:10949 failed (98: Address already in use)
2018-04-14T17:09:25.440569Z app[web.1]: 2018/04/14 17:09:24 [emerg] 159#0: bind() to 0.0.0.0:10949 failed (98: Address already in use)
2018-04-14T17:09:25.940679Z app[web.1]: nginx: [emerg] bind() to 0.0.0.0:10949 failed (98: Address already in use)
2018-04-14T17:09:25.940746Z app[web.1]: 2018/04/14 17:09:24 [emerg] 159#0: bind() to 0.0.0.0:10949 failed (98: Address already in use)
2018-04-14T17:09:26.440833Z app[web.1]: nginx: [emerg] bind() to 0.0.0.0:10949 failed (98: Address already in use)
2018-04-14T17:09:26.440876Z app[web.1]: 2018/04/14 17:09:24 [emerg] 159#0: bind() to 0.0.0.0:10949 failed (98: Address already in use)
2018-04-14T17:09:26.940976Z app[web.1]: nginx: [emerg] still could not bind()
2018-04-14T17:09:26.941031Z app[web.1]: 2018/04/14 17:09:24 [emerg] 159#0: still could not bind()
2018-04-14T17:09:26.941552Z app[web.1]: buildpack=nginx at=exit process=nginx
2018-04-14T17:09:26.946943Z system[web.1]: Process exited (exit status 1)
2018-04-14T17:09:26.965949+00:00 system[web.1]: State changed from up to crashed

最佳答案

请在您的 Procfile 中将服务器端口更改为 --server.port=$PORT。 Heroku 会为您动态分配端口。

关于tomcat - Heroku 上的 Spring Boot 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49821953/

相关文章:

java - 如何在 camunda 中建模异步服务任务并在 Spring Boot 中实现

java - 是否可以动态设置 SpringBootTest 属性?

mongodb - SailsJS 部署到 Heroku,连接到 Mongolabs MongoDB

javascript - heroku Nodejs 应用程序在部署后崩溃

node.js - mongoDB - 使用 node.js 在多个字段中进行文本搜索

java - 添加/删除断点时 Eclipse 总是挂起几秒钟

java - 如何无缝地在tomcat中重新部署 war ?

java - 无法覆盖 Spring Boot 安全性

java - 为 Tomcat 配置 SSL 的步骤是什么?

macos - 无法停止在 Mac OS X 10.7.3 中通过 Macports 安装的 Tomcat6