这是我在命令行中调用heroku logs --tail时得到的结果。我试图弄清楚如何绑定到PORT环境变量。
- 2017-08-14T20:37:08.596686+00:00 heroku[web.1]: Starting process with command `npm start`
- 2017-08-14T20:37:12.430214+00:00 app[web.1]:
- 2017-08-14T20:37:12.430257+00:00 app[web.1]: > angular-seed@0.0.0 prestart /app
- 2017-08-14T20:37:12.430258+00:00 app[web.1]: > npm install
- 2017-08-14T20:37:12.430258+00:00 app[web.1]:
- 2017-08-14T20:37:15.512607+00:00 app[web.1]:
- 2017-08-14T20:37:15.512635+00:00 app[web.1]: > angular-seed@0.0.0 postinstall /app
- 2017-08-14T20:37:15.512636+00:00 app[web.1]: > bower install
- 2017-08-14T20:37:15.512637+00:00 app[web.1]:
- 2017-08-14T20:37:16.486773+00:00 app[web.1]:
- 2017-08-14T20:37:16.486791+00:00 app[web.1]: > angular-seed@0.0.0 start /app
- 2017-08-14T20:37:16.486792+00:00 app[web.1]: > http-server -a localhost - p 8000 -c-1 ./app
- 2017-08-14T20:37:16.486793+00:00 app[web.1]:
- 2017-08-14T20:37:16.825832+00:00 app[web.1]: Starting up http-server, serving ./app
- 2017-08-14T20:37:16.825845+00:00 app[web.1]: Available on:
- 2017-08-14T20:37:16.826624+00:00 app[web.1]: http://localhost:8000
- 2017-08-14T20:37:16.827943+00:00 app[web.1]: Hit CTRL-C to stop the server
- 2017-08-14T20:37:20.747552+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/" host=portfolio- stacyareas.herokuapp.com request_id=f4146b40-cc31-4ca0-acc8-52e76b0cbd58 fwd="75.101.48.232" dyno= connect= service= status=503 bytes= protocol=https
- 2017-08-14T20:38:08.834223+00:00 app[web.1]: Error waiting for process to terminate: No child processes
- 2017-08-14T20:38:08.948625+00:00 heroku[web.1]: State changed from starting to crashed
- 2017-08-14T20:38:10.473956+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=portfolio- stacyareas.herokuapp.com request_id=9553660d-4199-407b-ab74-712e04940b06 fwd="75.101.48.232" dyno= connect= service= status=503 bytes= protocol=https
这是我在index.js文件中的内容
var express = require('express');
var app = express();
app.set('port', (process.env.PORT || 5000));
app.use(express.static(__dirname + '/public'));
// views is directory for all template files
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.get('/', function(request, response) {
response.render('pages/index');
});
app.listen(app.get('port'), function() {
console.log('Node app is running on port', app.get('port'));
});