繁体   English   中英

使用Scalatra在Heroku上部署

[英]Deploy on Heroku using Scalatra

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

谢谢。

您的应用程序绑定到端口8080,但是它需要绑定到在Heroku上设置为$PORT环境变量的$PORT 为此,您需要将-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

暂无
暂无

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

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