0

我正在尝试在 heroku 中部署我的 Scalatra Web 应用程序,但我遇到了一个问题。

我的应用程序在本地使用 SBT 并使用“heroku 本地网络”。我正在使用 heroku sbt 插件。

当我使用“sbt stage deployHeroku”时,应用程序被上传并正确启动,获得:


user@user-X550JF:~/Documents/SOFT/cloudrobe$ sbt stage deployHeroku
Detected sbt version 0.13.9
....
....
[info] Packaging /home/user/Documents/SOFT/cloudrobe/target/scala-2.11/cloudrobe_2.11-0.1.0-SNAPSHOT.war ...
[info] Done packaging.
[success] Total time: 2 s, completed May 25, 2016 1:04:51 AM
[info] -----> Packaging application...
[info]        - app: cloudrobe
[info]        - including: target/universal/stage/
[info] -----> Creating build...
[info]        - file: target/heroku/slug.tgz
[info]        - size: 45MB
[info] -----> Uploading slug... (100%)
[info]        - success
[info] -----> Deploying...
[info] remote: 
[info] remote: -----> Fetching set buildpack https://codon-buildpacks.s3.amazonaws.com/buildpacks/heroku/jvm-common.tgz... done
[info] remote: -----> sbt-heroku app detected
[info] remote: -----> Installing OpenJDK 1.8... done
[info] remote: 
[info] remote: -----> Discovering process types
[info] remote:        Procfile declares types -> web
[info] remote: 
[info] remote: -----> Compressing...
[info] remote:        Done: 93.5M
[info] remote: -----> Launching...
[info] remote:        Released v11
[info] remote:        https://cloudrobe.herokuapp.com/ deployed to Heroku
[info] remote: 
[info] -----> Done
___________________________________________________________________________

使用“heroku 日志”我可以看到:

2016-05-24T23:14:16.007200+00:00 app[web.1]: 23:14:16.006 [main] INFO  org.mongodb.driver.connection - Opened connection [connectionId{localValue:5, serverValue:5}] to localhost:33333
2016-05-24T23:14:16.370324+00:00 app[web.1]: 23:14:16.370 [main] INFO  o.f.s.servlet.ServletTemplateEngine - Scalate template engine using working directory: /tmp/scalate-5146893161861816095-workdir
2016-05-24T23:14:16.746719+00:00 app[web.1]: 23:14:16.746 [main] INFO  o.e.j.server.handler.ContextHandler - Started o.e.j.w.WebAppContext@7a356a0d{/,file:/app/src/main/webapp,AVAILABLE}
2016-05-24T23:14:16.782745+00:00 app[web.1]: 23:14:16.782 [main] INFO  o.e.jetty.server.ServerConnector - Started ServerConnector@7dc51783{HTTP/1.1}{0.0.0.0:8080}
2016-05-24T23:14:16.782924+00:00 app[web.1]: 23:14:16.782 [main] INFO  org.eclipse.jetty.server.Server - Started @6674ms

但是,5 或 10 秒后出现以下错误,表明连接已超时:

2016-05-24T23:52:32.962896+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/" host=cloudrobe.herokuapp.com request_id=a7f68d98-54a2-44b7-8f5f-47efce0f1833 fwd="52.90.128.17" dyno= connect= service= status=503 bytes=
2016-05-24T23:52:45.463575+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch

这是我使用端口 5000 的 Procfile:

web: target/universal/stage/bin/cloudrobe -Dhttp.address=127.0.0.1

谢谢你。

4

1 回答 1

0

您的应用程序绑定到端口 8080,但它需要绑定到$PORTHeroku 上设置为环境变量的端口。为此,您需要添加-Dhttp.port=$PORT到您的Procfile. 它还需要绑定到 0.0.0.0 而不是 127.0.0.1。所以它可能看起来像这样:

web: target/universal/stage/bin/cloudrobe -Dhttp.address=0.0.0.0 -Dhttp.port=$PORT
于 2016-05-25T00:52:22.480 回答