Peter Burdett
Peter Burdett

Reputation: 33

Running Dropwizard app on Heroku: R10 failed to bind to $PORT

I was recently pointed in the direction of dropwizard and heroku for the relatively easy creation and deployment of restFUL webservices.

Having followed the getting started tutorial at http://dropwizard.readthedocs.org/en/latest/getting-started.html I soon had a simple Hello World service running on my localhost, no problems at all.

Moving onto trying to deploy this on Heroku I have hit an issue. On deploying the app to heroku, I get an error

2014-08-14T11:34:59.869067+00:00 heroku[web.1]: State changed from starting to crashed
2014-08-14T11:34:59.070364+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web
process failed to bind to $PORT within 60 seconds of launch
2014-08-14T11:34:59.070573+00:00 heroku[web.1]: Stopping process with SIGKILL
2014-08-14T11:34:59.857478+00:00 heroku[web.1]: Process exited with status 137

My Procfile looks like....

web java $JAVA_OPTS -D.http.port=$PORT -jar target/exampleMavenProject-0.0.1-SNAPSHOT.jar server hello-world.yml

Which is exactly the same as the command line code to run the app on the local host, with the exception of

$JAVA_OPTS -D.http.port=$PORT

$JAVA_OPTS is definied within the herkou app config variables; and from my understanding $PORT can't be overridden.

And the hello-world.yml doesn't have any extra configuration variables in it other than those required for the dropwizard example

template: Hello, %s!

defaultName: Stranger

Does anyone have any suggestions as to why this doesn't work?

Thanks.

Upvotes: 3

Views: 1452

Answers (2)

Olesia
Olesia

Reputation: 142

Update for Dropwizard 1.0 with Gradle:

Procfile

web: java $JAVA_OPTS -Ddw.server.applicationConnectors[0].port='$PORT' -jar build/libs/yourJar-1.0-all.jar server config-production.yml

config-production.yml

server:
registerDefaultExceptionMappers: false
applicationConnectors:
    - type: http
      port: 8080

Upvotes: 1

Xinzz
Xinzz

Reputation: 2252

Dropwizard 0.7.x has changed their server configurations; in particular, http.port does not work anymore.

Instead, you should be using server.connector.port for your procfile/.yml files. Here's an example:

Procfile

web: java $JAVA_OPTS -Ddw.server.connector.port=$PORT -jar target/pos-tagger-1.0-SNAPSHOT.jar server src/main/resources/POSTagger.yml

POSTagger.yml

server:
  type: simple
  applicationContextPath: /
  adminContextPath: /admin
  connector:
    type: http
    port: 8080

If you want to see a full, working heroku example using 0.7.x, check out: https://github.com/xinranxiao/POSTagger

Upvotes: 6

Related Questions