gpt4 book ai didi

tomcat - Heroku 上的 Spring Boot 应用程序

转载 作者:行者123 更新时间:2023-11-28 23:15:42 25 4
gpt4 key购买 nike

我正在尝试在 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com