我在Heroku上託管了一個Express應用程序。本地它運行得很好,但在Heroku上不斷崩潰。每次我去它,我都會看到'應用程序錯誤'頁面。Heroku Node應用程序不斷崩潰
我仔細檢查了所有的環境變量,他們似乎確定。
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]: > [email protected] 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]: > [email protected] 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的指示部署你的應用程序? https://devcenter.heroku.com/articles/getting-started-with-nodejs#introduction –
是的,我遵循指南。我正在嘗試構建GitHub集成,所以關鍵在於GitHub。 – Yulek
你可以添加你的procfile嗎? –