I pushed a fairly simple node.js express app on heroku and can't make it works. It immeadiately crash. heroku tail --logs
gives me :
2017-05-23T04:43:08.156660+00:00 app[api]: Scaled to web@1:Free worker@0:Free by user jp@yetie.fr
2017-05-23T04:43:24.388293+00:00 heroku[web.1]: Starting process with command `: node server.js`
2017-05-23T04:43:26.207926+00:00 heroku[web.1]: Process exited with status 0
2017-05-23T04:43:26.220393+00:00 heroku[web.1]: State changed from starting to crashed
2017-05-23T04:43:26.221461+00:00 heroku[web.1]: State changed from crashed to starting
2017-05-23T04:43:43.343050+00:00 heroku[web.1]: Starting process with command `: node server.js`
2017-05-23T04:43:44.751608+00:00 heroku[web.1]: Process exited with status 0
2017-05-23T04:43:44.762870+00:00 heroku[web.1]: State changed from starting to crashed
2017-05-23T04:43:46.400260+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=yetie.herokuapp.com request_id=d7913d1e-64ab-497b-a59d-fda9454d6e69 fwd="81.56.46.53" dyno= connect= service= status=503 bytes= protocol=https
2017-05-23T04:43:46.899099+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=yetie.herokuapp.com request_id=1fdc61fb-eebe-40a2-8b0a-a71b09f7ff10 fwd="81.56.46.53" dyno= connect= service= status=503 bytes= protocol=https
I have a Procfile that contains :
web : node server.js
worker: node workers/match.js
worker, run as expected. server.js looks like this :
const express = require('express');
const app = express();
app.use(express.static(__dirname + '/testheroku'));
app.listen(process.env.PORT || 8080, function(){
console.log("Express server listening on port %d in %s mode", this.address().port, app.settings.env);
});
In /testheroku dir there is a single "hello world" html file.
When I run it locally with heroku local web
it works, when I run it by connecting to heroku dyno with heroku run bash
then node server.js
and then doing a wget http://localhost:xxxx
it properly get the "hello world" html file.
But when I try to access the url heroku gives to me when I build the app, I get the above crash logs.
Node and npm versions are the same locally and on heroku :
node --version => v6.10.3
npm --version => 3.10.10
I may include the package.json file if requested, but it's fairly long (based on a more complex angular2 app) and it compiles properly both localy and on heroku. And as I manage to run node server.js
by connecting to the dyno thru bash, I doubt the issue should be there.
Most answers I found on stackoveflow or elswere suggest a port issue and to use the app.listen(process.env.PORT || 8080)
trick, which I did. So what am I missing here ?
via Jean-Philippe
No comments:
Post a Comment