我使用類型安全配置的配置來獲得環境變量是這樣的:
service {
host = "localhost"
host = ${?HOST}
port = 8080
port = ${?PORT}
ports {
tcp = 6969
ws = 6696
}
}
在我Boot.scala
我寫道:
val host = config.getString("service.host")
val portHTTP = config.getInt("service.port")
val rootService = system.actorOf(Props(new RootService()))
IO(Http) ! Http.Bind(rootService, interface = host, port = portHTTP)
這應該是蠻好的!我看見heroku log
信息:
2014-08-30T17:39:38.867872+00:00 app[web.1]: [spray-blog-akka.actor.default-dispatcher-4] [akka://spray-blog/user/IO-HTTP/listener-0] Bound to localhost/127.0.0.1:25870
2014-08-30T17:40:37.007696+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
好像我已經綁定到特定端口:Bound to localhost/127.0.0.1:25870
,但60秒後的Heroku仍然說,我沒有綁定到它的時候了!
我複製並從Heroku的粘貼我的啓動腳本提供了示例應用程序:web: target/start com.mturk.Boot -Dhttp.port=${PORT} -Dconfig.file=conf/application.conf
我想不出是什麼問題!太沮喪了!