【发布时间】:2017-04-16 23:18:26
【问题描述】:
我有一个托管在 Heroku 上的 Express 应用。在本地它运行得很好,但一直在 Heroku 上崩溃。每次我去它时,我都会得到“应用程序错误”页面。
我仔细检查了所有环境变量,它们看起来还不错。
Heroku 日志并不能提供太多帮助:
2017-04-16T23:02:49.001768+00:00 heroku[web.1]: State changed from crashed
to starting
2017-04-16T23:02:52.072906+00:00 heroku[web.1]: Starting process with
command `npm run start`
2017-04-16T23:02:56.042611+00:00 app[web.1]:
2017-04-16T23:02:56.042628+00:00 app[web.1]: > my-app@0.0.1 start /app
2017-04-16T23:02:56.042629+00:00 app[web.1]: > node bin/app
2017-04-16T23:02:56.042630+00:00 app[web.1]:
2017-04-16T23:02:57.200912+00:00 heroku[web.1]: State changed from starting
to crashed
2017-04-16T23:02:57.201454+00:00 heroku[web.1]: State changed from crashed
to starting
2017-04-16T23:02:57.192198+00:00 heroku[web.1]: Process exited with status 0
2017-04-16T23:03:00.981528+00:00 heroku[web.1]: Starting process with
command `npm run start`
2017-04-16T23:03:04.312475+00:00 app[web.1]:
2017-04-16T23:03:04.312489+00:00 app[web.1]: > my-app@0.0.1 start /app
2017-04-16T23:03:04.312490+00:00 app[web.1]: > node bin/app
2017-04-16T23:03:04.312491+00:00 app[web.1]:
2017-04-16T23:03:06.093211+00:00 heroku[web.1]: Process exited with status 0
2017-04-16T23:03:06.112842+00:00 heroku[web.1]: State changed from starting
to crashed
然后我尝试手动启动应用程序:
$ heroku run bash
...
$ npm run start
我没有错误。我正在使用 pm2 进程管理器,所以我检查了它以查看应用程序是否正在运行,并且看起来是这样的:
$ node_modules/.bin/pm2 list
...
但是当我打开我的应用程序时,我得到了与以前相同的“应用程序错误”页面。
'heroku restart' 没有帮助。它只是每次都会再次崩溃。
我的本地环境和 Heroku 之间的唯一区别(至少据我所知......)是我在本地有一个文件,我正在从中读取 RSA 私钥,并且在 Heroku 上读取了该密钥来自环境。
编辑:根据要求,这是我的 Procfile:
web: npm run start
有什么想法吗?
【问题讨论】:
-
RSA 私钥有什么作用?您是否按照 Heroku 的说明部署您的应用程序? devcenter.heroku.com/articles/…
-
是的,我按照指南进行操作。我正在尝试构建 GitHub 集成,所以关键是 GitHub。
-
你能添加你的 procfile 吗?
-
Procfile 添加。
标签: node.js express heroku pm2