Running Dropwizard app on Heroku: R10 failed to bind to $ PORT
I recently pointed towards dropwizard and heroku for a relatively simple creation and deployment of restful web services.
Following the initial tutorial at http://dropwizard.readthedocs.org/en/latest/getting-started.html I soon had a simple Hello World service running on my localhost, no problem at all.
Moving on to trying to deploy this to Heroku, I hit a problem. When deploying the app to heroku, I get the 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
This is exactly the same as the command line code to run the application on localhost, except
$JAVA_OPTS -D.http.port=$PORT
$ JAVA_OPTS is defined in the herkou application config variables; and from my understanding $ PORT cannot be overridden.
And hello-world.yml doesn't contain any additional config variables other than those required for the dropwizard example
template: Hello, %s!
defaultName: Stranger
Does anyone have any suggestions as to why this is not working?
Thank.
source to share
Dropwizard 0.7.x changed its server configuration; in particular http.port
no longer works.
Instead, you should use server.connector.port
procfile / .yml for your 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 complete, working example of hero using 0.7.x check out: https://github.com/xinranxiao/POSTagger
source to share
Update for Dropwizard 1.0 using 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
source to share