2

I have a Scala app (http4s with Jetty) that I want to deploy to Heroku. I followed the instructions on https://devcenter.heroku.com/articles/getting-started-with-scala and has this as my Procfile:

web: target/universal/stage/bin/myappname

I build the app using sbt with sbt-native-packager and run sbt compile stage. On my local machine when I run target/universal/stage/bin/myappname I can start the Jetty server successfully with the following logs:

Starting on port 4000
[main] INFO org.eclipse.jetty.util.log - Logging initialized @285ms
[main] INFO org.eclipse.jetty.server.Server - jetty-9.2.3.v20140905
[main] INFO org.eclipse.jetty.server.handler.ContextHandler - Started o.e.j.s.ServletContextHandler@45c5082a{/,null,AVAILABLE}
[main] INFO org.eclipse.jetty.server.ServerConnector - Started ServerConnector@30ec6243{HTTP/1.1}{127.0.0.1:4000}
[main] INFO org.eclipse.jetty.server.Server - Started @421ms

On Heroku I also get the log that the Jetty server started but also an additional timeout line after:

2014-11-22T19:27:53.648838+00:00 heroku[web.1]: Starting process with command `target/universal/stage/bin/myappname`
2014-11-22T19:27:54.967288+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx384m -Djava.rmi.server.useCodebaseOnly=true
2014-11-22T19:27:55.495116+00:00 app[web.1]: Starting on port 36115
2014-11-22T19:27:55.761411+00:00 app[web.1]: [main] INFO org.eclipse.jetty.util.log - Logging initialized @645ms
2014-11-22T19:27:56.032766+00:00 app[web.1]: [main] INFO org.eclipse.jetty.server.handler.ContextHandler - Started o.e.j.s.ServletContextHandler@397f0e73{/,null,AVAILABLE}
2014-11-22T19:27:55.962916+00:00 app[web.1]: [main] INFO org.eclipse.jetty.server.Server - jetty-9.2.3.v20140905
2014-11-22T19:27:56.055280+00:00 app[web.1]: [main] INFO org.eclipse.jetty.server.Server - Started @967ms
2014-11-22T19:27:56.055064+00:00 app[web.1]: [main] INFO org.eclipse.jetty.server.ServerConnector - Started ServerConnector@1df3b191{HTTP/1.1}{127.0.0.1:36115}
2014-11-22T19:28:07.147193+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/" host=myappname.herokuapp.com request_id=c05b5bf6-6268-4c37-8525-4e58c1bda496 fwd="24.4.136.119" dyno= connect= service= status=503 bytes=

What is the reason that my app started yet Heroku says App boot timeout? Thanks in advance.

tuzhucheng
  • 158
  • 3
  • 9
  • 1
    For me, changing `BlazeBuilder.bindHttp(Properties.envOrElse("PORT", "8080").toInt)` to `BlazeBuilder.bindHttp(Properties.envOrElse("PORT", "8080").toInt, "0.0.0.0")` fixed the problem (I'm using the Blaze backend instead of Jetty, but it should not make a difference). – Lauri Lehmijoki Nov 13 '15 at 13:41

2 Answers2

1

You're likely listening on localhost rather than on 0.0.0.0

Martijn
  • 11,964
  • 12
  • 50
  • 96
0

Looking around here for answers involving that error code, I have the following suggestions:

  • Make sure you can start your app locally with foreman start
  • Find out how to start an https/Jetty app on a different port (I haven't used it)
    • (As an example, I'll use what works for Play2, which is setting http.port)
  • Edit your Procfile, appending an http.port argument that uses $PORT like this:

web: target/universal/stage/bin/myappname -Dhttp.port=$PORT

I suspect that without this port-setting argument, your webapp is starting on a different port to the one Heroku is checking for, hence the timeout.

Community
  • 1
  • 1
millhouse
  • 9,817
  • 4
  • 32
  • 40
  • I am able to start my app locally with `foreman start`. My code starts the app on the port defined by the environment variable PORT: `val port = Properties.envOrElse("PORT", "8080").toInt`. I've also added the `-Dhttp.port=$PORT` to the Procfile without success. – tuzhucheng Nov 23 '14 at 18:54
  • How long does it take for your app to start locally? In your Heroku log it looks like everything is fine until it hangs waiting for "org.eclipse.jetty.server.Server - Started". Any idea if something in your app could cause this? – codefinger Dec 05 '14 at 14:57