【问题标题】:Sails.js app fails to deploy on herokuSails.js 应用程序无法在 heroku 上部署
【发布时间】:2015-02-10 04:29:37
【问题描述】:

我的sails.js 应用程序在本地主机上运行良好,但在heroku 上失败。

我的 production.js 中有以下设置

  port: process.env.PORT || 1337,
  environment: process.env.NODE_ENV || 'development',

仍然收到以下消息并且部署失败;

2015-02-10T03:54:55.089482+00:00 app[web.1]: Tue, 10 Feb 2015 03:54:55 GMT i18n:debug read /app/config/locales/de.json for locale: de
2015-02-10T03:54:55.089220+00:00 app[web.1]: Tue, 10 Feb 2015 03:54:55 GMT i18n:debug will write to /app/config/locales/fr.json
2015-02-10T03:54:55.089261+00:00 app[web.1]: Tue, 10 Feb 2015 03:54:55 GMT i18n:debug read /app/config/locales/fr.json for locale: fr
2015-02-10T03:54:55.089453+00:00 app[web.1]: Tue, 10 Feb 2015 03:54:55 GMT i18n:debug will write to /app/config/locales/de.json
2015-02-10T03:54:55.138917+00:00 app[web.1]: designed for a production environment, as it will leak
2015-02-10T03:54:55.138919+00:00 app[web.1]: memory, and will not scale past a single process.
2015-02-10T03:54:55.393772+00:00 app[web.1]: http hook loaded successfully.
2015-02-10T03:54:55.396900+00:00 app[web.1]: sockets hook loaded successfully.
2015-02-10T03:54:55.397665+00:00 app[web.1]: Located 0 user hook(s)...
2015-02-10T03:54:55.413955+00:00 app[web.1]: Setting default Express view engine to jade...
2015-02-10T03:54:55.415525+00:00 app[web.1]: Loading adapter ( sails-mongo ) for user  from `node_modules` directory...
2015-02-10T03:54:55.394180+00:00 app[web.1]: Configuring socket (ws://) server...
2015-02-10T03:54:55.397318+00:00 app[web.1]: Loading user hooks...
2015-02-10T03:54:55.397942+00:00 app[web.1]: views hook loaded successfully.
2015-02-10T03:54:55.414283+00:00 app[web.1]: Initialized 0 user hook(s)...
2015-02-10T03:54:55.414314+00:00 app[web.1]: userhooks hook loaded successfully.
2015-02-10T03:54:55.415058+00:00 app[web.1]: Forcing Waterline to use `migrate: "safe" strategy (since this is production)
2015-02-10T03:54:55.606849+00:00 app[web.1]: Starting ORM...
2015-02-10T03:54:55.771204+00:00 app[web.1]: pubsub hook loaded successfully.
2015-02-10T03:54:55.931003+00:00 app[web.1]: Grunt :: >> Local Npm module "grunt-simple-mocha" not found. Is it installed?
2015-02-10T03:54:55.769438+00:00 app[web.1]: orm hook loaded successfully.
2015-02-10T03:54:56.159039+00:00 app[web.1]: Grunt :: Running "clean:dev" (clean) task
2015-02-10T03:54:56.180324+00:00 app[web.1]: Grunt :: >> Destination not written because compiled files were empty.
2015-02-10T03:54:56.184386+00:00 app[web.1]: Grunt :: Running "copy:dev" (copy) task
2015-02-10T03:54:56.180479+00:00 app[web.1]: Grunt :: Running "less:dev" (less) task
2015-02-10T03:54:56.162834+00:00 app[web.1]: Grunt :: Running "jst:dev" (jst) task
2015-02-10T03:54:56.729594+00:00 app[web.1]: Grunt :: , copied 542 files
2015-02-10T03:54:56.729493+00:00 app[web.1]: Grunt :: Created 4 directories
2015-02-10T03:54:56.730009+00:00 app[web.1]: Grunt :: Running "coffee:dev" (coffee) task
2015-02-10T03:54:56.856265+00:00 app[web.1]: Grunt :: Running "concat:js" (concat) task
2015-02-10T03:54:57.062061+00:00 app[web.1]: Grunt :: File ".tmp/public/concat/production.js" created.
2015-02-10T03:54:57.063749+00:00 app[web.1]: Grunt :: File ".tmp/public/concat/production.css" created.
2015-02-10T03:54:57.064113+00:00 app[web.1]: Grunt :: Running "uglify:dist" (uglify) task
2015-02-10T03:54:57.062590+00:00 app[web.1]: Grunt :: Running "concat:css" (concat) task
2015-02-10T03:55:53.360980+00:00 heroku[web.1]: Stopping process with SIGKILL
2015-02-10T03:55:53.360980+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2015-02-10T03:55:54.179225+00:00 heroku[web.1]: Process exited with status 137
2015-02-10T03:55:54.193814+00:00 heroku[web.1]: State changed from starting to crashed

请指教,谢谢。

【问题讨论】:

  • 您使用的是什么端口,该端口是否已在网络服务器上使用?
  • 从环境设置端口 => "port: process.env.PORT || 1337",在本地运行时端口为1337。
  • 您是否在使用相同 $PORT 环境变量的同一台服务器上运行另一个应用程序?您始终可以尝试在生产中明确设置端口。在升帆时使用 --verbose 标志检查详细日志也是一个好主意
  • 我已经有“傻”级别的日志记录,比详细更详细,上面的帖子就是那个输出。我怀疑咕噜声需要太长时间才能升起帆和启动超时???不太确定...

标签: node.js heroku sails.js waterline


【解决方案1】:

您的应用正在生产模式下运行。因为Forcing Waterline to use `migrate: "safe" strategy (since this is production) 和 concat/uglify 任务正在运行,我可以说出来。

这个进程(concat/uglify)可能正在破坏分配的内存。在需要处理大量 js/css 的小型 heroku 实例上部署时,我已经看到了这一点。您可能想尝试 https://github.com/mbuchetics/heroku-buildpack-nodejs-grunt 在部署而不是启动时运行 grunt。

请参阅http://blog.mdarveau.com/2014/10/20/deploying-to-heroku,了解我在 Heroku 上部署 Sails 应用程序的经验。

日志中的以下部分很奇怪:

2015-02-10T03:54:55.138917+00:00 app[web.1]: designed for a production environment, as it will leak
2015-02-10T03:54:55.138919+00:00 app[web.1]: memory, and will not scale past a single process.

【讨论】:

  • 安装 buildpack 解决了这个问题。我的配置是正确的,除了 Grunt 任务,我不需要更改任何内容。我知道他们有问题。我将sails 默认prod 任务重命名为heroku,并添加了一个空的prod 任务。应用程序现在开始正常!谢谢!
【解决方案2】:

在 config/models.js 中设置 migrate: 'alter'

【讨论】:

    【解决方案3】:

    快速(临时)解决方案只是删除生产标志

    delete process.env.NODE_ENV;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-04-07
      • 2016-06-23
      • 2013-08-22
      • 2018-04-11
      • 1970-01-01
      • 1970-01-01
      • 2017-03-09
      • 1970-01-01
      相关资源
      最近更新 更多