我的Heroku应用程序无法启动,当我在浏览器中加载页面时,它只是给我通用的
应用程序错误
应用程序中发生错误,您的页面无法执行 提供服务。请稍后再试。
如果您是应用程序所有者,请查看日志以获取详细信息。
我检查我的heroku日志几乎没有说“State changed from starting to crashed
”。
2015-04-01T23:10:13.629849+00:00 heroku[api]: Release v12 created by xxxx@gmail.com
2015-04-01T23:10:13.629849+00:00 heroku[api]: Deploy 7d3ab9f by xxxx@gmail.com
2015-04-01T23:10:13.748810+00:00 heroku[web.1]: State changed from crashed to starting
2015-04-01T23:10:15.398769+00:00 heroku[web.1]: Starting process with command `node routes/index.js`
2015-04-01T23:10:17.007727+00:00 app[web.1]: Detected 512 MB available memory, 512 MB limit per process (WEB_MEMORY)
2015-04-01T23:10:17.007751+00:00 app[web.1]: Recommending WEB_CONCURRENCY=1
2015-04-01T23:10:18.163323+00:00 heroku[web.1]: Process exited with status 0
2015-04-01T23:10:18.184341+00:00 heroku[web.1]: State changed from starting to crashed
当我在浏览器中加载页面并看到上面的错误时,日志显示
2015-04-01T23:11:20.387769+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=surrealist-debate.herokuapp.com request_id=2c304a35-950a-422d-9174-4d558cbd4d40 fwd="172.3.184.57" dyno= connect= service= status=503 bytes=
2015-04-01T23:11:20.727572+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=surrealist-debate.herokuapp.com request_id=474f2a28-31eb-4c93-9371-db91ec0f4427 fwd="172.3.184.57" dyno= connect= service= status=503 bytes=
这是我的 package.json :
{
"name": "surrealist-debate",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www"
},
"dependencies": {
"body-parser": "~1.12.0",
"cookie-parser": "~1.3.4",
"debug": "~2.1.1",
"express": "~4.12.2",
"hjs": "~0.0.6",
"morgan": "~1.5.1",
"serve-favicon": "~2.2.0"
}
}
通过 foreman foreman start web
使用此 Procfile
web: node routes/index.js
领班只是给了我这个错误:
16:31:34 web.1 | started with pid 12073
16:31:34 web.1 | exited with code 0
16:31:34 system | sending SIGTERM to all processes
我可以然后使用 DEBUG 直接在本地运行它:
DEBUG=surrealist-debate:* ./bin/www
它在本地工作:
surrealist-debate:server Listening on port 3000 +0ms
发生什么事了?!我怎样才能让它在Heroku和工头上运行而不仅仅是退出并立即崩溃而没有信息?
答案 0 :(得分:0)
好的,似乎问题只是 Procfile !当它应该指向routes/index.js
时,它试图运行bin/www
(然后执行它的事情就会执行index.js,而index.js会提供正确的视图/ index.hjs)
对于所有其他在日志中看不到相关信息但没有信息的人,请检查 Procfile ;)