heroku + node + express + hogan 无法启动,日志中没有信息

heroku + node + express + hogan wont start, no info in the logs

我的 Heroku 应用程序无法启动,当我在浏览器中加载页面时,它只给我通用的

Application Error

An error occurred in the application and your page could not be served. Please try again in a few moments.

If you are the application owner, check your logs for details.

而且我检查我的 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

foreman 给我这个错误:

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

可以但是运行它直接在本地使用DEBUGDEBUG=surrealist-debate:* ./bin/www

它在本地工作: surrealist-debate:server Listening on port 3000 +0ms

这是怎么回事?!我怎样才能在 Heroku 和工头上将其发送到 运行 而不是在没有任何信息的情况下立即退出并崩溃?

好的,看来问题出在 Procfile 上!当它应该指向 bin/www 时它试图 运行 routes/index.js (它做它的事情然后执行 index.js,这反过来服务于正确的 views/index .hjs)

对于看到类似错误但日志中没有信息的所有其他人,请检查您的 Procfile ;)