0

我正在尝试在heroku中进行新的部署,似乎无法毫无问题地运行。

我不断收到此错误

错误 R11(错误绑定)-> 绑定到端口 5768 的进程,应为 41113(请参阅环境变量 PORT)

档案

web: geddy -p 5768

包.json

{
  "name": "oskalisti",
  "version": "0.0.1",
  "dependencies": {
    "geddy": "0.3.20",
    "jake": "0.2.31"
  }
}

完整日志:

2012-04-13T17:47:26+00:00 app[web.1]: [Fri, 13 Apr 2012 17:47:26 GMT] INFO Server starting with config: {
2012-04-13T17:47:26+00:00 app[web.1]:   "environment": "development",
2012-04-13T17:47:26+00:00 app[web.1]:   "workers": 1,
2012-04-13T17:47:26+00:00 app[web.1]:   "port": "5768",
2012-04-13T17:47:26+00:00 app[web.1]:   "debug": true,
2012-04-13T17:47:26+00:00 app[web.1]:   "rotateWorkers": false,
2012-04-13T17:47:26+00:00 app[web.1]:   "rotationWindow": 7200000,
2012-04-13T17:47:26+00:00 app[web.1]:   "rotationTimeout": 300000,
2012-04-13T17:47:26+00:00 app[web.1]:   "logDir": "/app/log",
2012-04-13T17:47:26+00:00 app[web.1]:   "gracefulShutdownTimeout": 30000,
2012-04-13T17:47:26+00:00 app[web.1]:   "heartbeatInterval": 5000,
2012-04-13T17:47:26+00:00 app[web.1]:   "heartbeatWindow": 20000,
2012-04-13T17:47:26+00:00 app[web.1]:   "staticFilePath": "/app/public",
2012-04-13T17:47:26+00:00 app[web.1]:     "store": "memory",
2012-04-13T17:47:26+00:00 app[web.1]:     "key": "sid",
2012-04-13T17:47:26+00:00 app[web.1]:   "sessions": {
2012-04-13T17:47:26+00:00 app[web.1]:     "expiry": 1209600
2012-04-13T17:47:26+00:00 app[web.1]:   "cookieSessionKey": "sdata",
2012-04-13T17:47:26+00:00 app[web.1]:   "metrics": null,
2012-04-13T17:47:26+00:00 app[web.1]:   },
2012-04-13T17:47:26+00:00 app[web.1]:   "i18n": {
2012-04-13T17:47:26+00:00 app[web.1]:     "defaultLocale": "en-us",
2012-04-13T17:47:26+00:00 app[web.1]:     "loadPaths": [
2012-04-13T17:47:26+00:00 app[web.1]:       "/app/config/locales"
2012-04-13T17:47:26+00:00 app[web.1]:     ]
2012-04-13T17:47:26+00:00 app[web.1]:   },
2012-04-13T17:47:26+00:00 app[web.1]:   "ssl": null,
2012-04-13T17:47:26+00:00 app[web.1]:   "model": {
2012-04-13T17:47:26+00:00 app[web.1]:     "useTimestamps": false,
2012-04-13T17:47:26+00:00 app[web.1]:     "forceCamel": true
2012-04-13T17:47:26+00:00 app[web.1]:   },
2012-04-13T17:47:26+00:00 app[web.1]:   "detailedErrors": true,
2012-04-13T17:47:26+00:00 app[web.1]:   "hostname": null
2012-04-13T17:47:26+00:00 app[web.1]: }
2012-04-13T17:47:26+00:00 app[web.1]: [Fri, 13 Apr 2012 17:47:26 GMT] INFO Creating 1 worker process.
2012-04-13T17:47:26+00:00 app[web.1]: [Fri, 13 Apr 2012 17:47:26 GMT] INFO Server worker running in development on port 5768 with a PID of: 6
2012-04-13T17:47:26+00:00 app[web.1]: [Fri, 13 Apr 2012 17:47:26 GMT] DEBUG LOGGING STARTED ============================================
2012-04-13T17:47:26+00:00 app[web.1]: [Fri, 13 Apr 2012 17:47:26 GMT] DEBUG ============================================================
2012-04-13T17:47:27+00:00 heroku[web.1]: Error R11 (Bad bind) -> Process bound to port 5768, should be 22421 (see environment variable PORT)

任何帮助将不胜感激。谢谢。

4

1 回答 1

6

好的,找到问题了,我傻了。

在 Procfile 上,我不应该使用端口号,heroku 将使用 $PORT 变量为我提供该端口。

所以我使 Procfile 看起来像这样:

web: geddy -p $PORT

这奏效了。我还修改了 production.js 环境配置文件以使用 heroku 端口,如下所示:

var config = {
  detailedErrors: false
, hostname: null
, port: process.env.PORT
, sessions: {
    store: 'memory'
  , key: 'sid'
  , expiry: 14 * 24 * 60 * 60
  }
};

module.exports = config;

注意port: process.env.PORT那里的行。

然后,如果您以这种方式更改文件,而不是在 Procfile 文件上使用 $PORT 变量,您可以像这样启动 geddy:

web: geddy -e production

只是更好的做法,这样您的生产配置就会被加载,并且您可以真正支持不同的环境。

于 2012-04-14T16:52:34.633 回答