我最近被指向 dropwizard 和 heroku 的方向,以便相对容易地创建和部署 restFUL web 服务。
已按照 http://dropwizard.readthedocs.org/en/latest/getting-started.html 上的入门教程进行操作我很快就在我的本地主机上运行了一个简单的 Hello World 服务,完全没有问题。
继续尝试在 Heroku 上部署它,我遇到了一个问题。将应用程序部署到 heroku 时,出现错误
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
我的 Procfile 看起来像......
web java $JAVA_OPTS -D.http.port=$PORT -jar target/exampleMavenProject-0.0.1-SNAPSHOT.jar server hello-world.yml
这与在本地主机上运行应用程序的命令行代码完全相同,除了
$JAVA_OPTS -D.http.port=$PORT
$JAVA_OPTS 在 herkou 应用程序配置变量中定义;根据我的理解, $PORT 不能被覆盖。
除了 dropwizard 示例所需的变量之外,hello-world.yml 中没有任何额外的配置变量
template: Hello, %s!
defaultName: Stranger
有没有人对为什么这不起作用有任何建议?
谢谢。
最佳答案
Dropwizard 0.7.x 改变了他们的服务器配置;特别是,http.port
不再起作用。
相反,您应该为您的 procfile/.yml 文件使用 server.connector.port
。这是一个例子:
简介
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
如果您想使用 0.7.x 查看完整、有效的 heroku 示例,请查看:https://github.com/xinranxiao/POSTagger
关于java - 在 Heroku 上运行 Dropwizard 应用 : R10 failed to bind to $PORT,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25307586/