Heroku / Clojure部署的端口错误

时间:2012-01-01 20:28:01

标签: web-applications deployment clojure heroku

这是我Heroku / Clojure problem here的后续问题。正如该线程所述,我能够将我的应用程序推送到Heroku的主人,然后部署它。

但是当我尝试转到我应用的网址时,我收到以下错误。这是一个奇怪的端口错误,但我不认为我在Heroku上部署Clojure应用程序时可以控制这些细节。我认为我的设置很简单。有什么办法可以解决这个错误吗?

Procfile


    web: lein run -m http.handler

http.handler


    ...
    (def app      (handler/site main))

错误


    2011-12-31T04:10:02+00:00 app[web.1]: Listening for transport dt_socket at address: 41208
    2011-12-31T04:10:03+00:00 heroku[web.1]: Stopping process with SIGKILL    2011-12-31T04:10:03+00:00 heroku[web.1]: Error R11 (Bad bind) -> Process bound to port 41208, should be 55032 (see environment variable PORT)
    2011-12-31T04:10:04+00:00 heroku[web.1]: State changed from starting to crashed
    2011-12-31T04:10:05+00:00 heroku[web.1]: Process exited
    2011-12-31T04:20:08+00:00 heroku[web.1]: State changed from crashed to created    2011-12-31T04:20:08+00:00 heroku[web.1]: State changed from created to starting    2011-12-31T04:20:12+00:00 heroku[web.1]: Starting process with command `lein run -m http.handler`
    2011-12-31T04:20:16+00:00 app[web.1]: Listening for transport dt_socket at address: 49151    2011-12-31T04:20:16+00:00 heroku[web.1]: Error R11 (Bad bind) -> Process bound to port 49151, should be 39092 (see environment variable PORT)
    2011-12-31T04:20:16+00:00 heroku[web.1]: Stopping process with SIGKILL
    2011-12-31T04:20:17+00:00 heroku[web.1]: State changed from starting to crashed
    2011-12-31T04:20:18+00:00 heroku[web.1]: Process exited
    2011-12-31T04:31:13+00:00 heroku[web.1]: State changed from crashed to created
    2011-12-31T04:31:13+00:00 heroku[web.1]: State changed from created to starting
    2011-12-31T04:31:16+00:00 heroku[web.1]: Starting process with command `lein run -m http.handler`
    2011-12-31T04:31:20+00:00 app[web.1]: Listening for transport dt_socket at address: 44321
    2011-12-31T04:31:20+00:00 heroku[web.1]: Error R11 (Bad bind) -> Process bound to port 44321, should be 17211 (see environment variable PORT)
    2011-12-31T04:31:20+00:00 heroku[web.1]: Stopping process with SIGKILL
    2011-12-31T04:31:22+00:00 heroku[web.1]: State changed from starting to crashed
    2011-12-31T04:31:22+00:00 heroku[web.1]: Process exited
    2011-12-31T04:44:59+00:00 heroku[web.1]: State changed from crashed to created
    2011-12-31T04:44:59+00:00 heroku[web.1]: State changed from created to starting
    2011-12-31T04:45:02+00:00 heroku[web.1]: Starting process with command `lein run -m http.handler`
    2011-12-31T04:45:05+00:00 app[web.1]: Listening for transport dt_socket at address: 37500
    2011-12-31T04:45:06+00:00 heroku[web.1]: Error R11 (Bad bind) -> Process bound to port 37500, should be 14046 (see environment variable PORT)
    2011-12-31T04:45:06+00:00 heroku[web.1]: Stopping process with SIGKILL
    2011-12-31T04:45:07+00:00 heroku[web.1]: State changed from starting to crashed
    2011-12-31T04:45:07+00:00 heroku[web.1]: Process exited
    2011-12-31T04:49:22+00:00 heroku[router]: Error H10 (App crashed) -> GET bkeeping.herokuapp.com/ dyno= queue= wait= service= status=503 bytes=
    2011-12-31T04:49:31+00:00 heroku[router]: Error H10 (App crashed) -> GET bkeeping.herokuapp.com/favicon.ico dyno= queue= wait= service= status=503 bytes=

好像有similar problem with Nodejs。但同样,我认为我无法控制Compojure / Ring / Jetty部署中的端口分配。我错了吗?这种行为会随着Webnoir而改变吗?

由于

2 个答案:

答案 0 :(得分:3)

确保您的处理程序绑定到正确的端口。

Heroku通过环境变量$PORT提供了一个端口号,因此在您app

中定义http.handler后,您的代码应该在某处
(let [port (Integer/parseInt (System/getenv "PORT"))]
  (run-jetty app {:port port}))

答案 1 :(得分:0)

虽然我得到了一些非常好的提示,但我终于无法通过这个了。事实证明我的project.clj有一个包含这个JDPA配置的defproject:


    :jvm-opts ["-agentlib:jdwp=transport=dt_socket,server=y,suspend=n"]

我应该早点注意到它。但它只是在本地工作,所以我没想到要质疑它。希望这可以帮助那些遇到同样障碍的人。