Heroku returns Process exited with status 143

2019-09-04 16:43发布

问题:

I'm about to finish an Ionic2 application that uses socket.io. I use to run (locally) my app with ionic serve (client side) in one terminal and with node index.js (server side) on another terminal. (index.js file is inside my ionic2 project folder). Now I want to try this out with Heroku.

These are the server side files I have:

My index.js file looks like this:

var io = require('socket.io'),
    http = require('http'),
    server = http.createServer(),
    io = io.listen(server);
...
...
my real code here
...
...
server.listen(process.env.PORT || 3000, function(){
  console.log('Server started, listening on' + process.env.PORT);
});

along with index.js I created (npm init) a package json which looks like this:

{
  "name": "myApplication",
  "version": "0.2.5",
  "description": "just a server",
  "engines": {
    "node": "4.2.6"
  },
  "main": "index.js",
  "scripts": {
    "start": "node index.js"
  },
  "dependencies": {
    "ejs": "2.4.1",
    "express": "4.13.3",
    "socket.io": "^1.5.0"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/xxxxxxxxx"
  },
  "keywords": [
    "node",
    "heroku",
    "express"
  ],
  "license": "MIT"
}

Procfile content is this: web: node index.js

While app.json holds this:

{
  "name": "MyAppServer",
  "description": "",
  "repository": "https://github.com/xxxxxxxx",
  "logo": "http://node-js-sample.herokuapp.com/node.svg",
  "keywords": ["node", "express", "static"],
  "image": "heroku/nodejs"
}

Before pushing all this stuff into github repo I've done npm install so I got node_modules folder. So I pushed everything on a github repo and then heroku login, heroku create. Finally git push heroku master returned me Build succeeded but now, when I do heroku open I see a page which says Application Error.

These are the warnings I get when I do heroku logs:

    2016-10-31T14:00:05.707656+00:00 heroku[web.1]: Idling
    2016-10-31T14:00:05.708289+00:00 heroku[web.1]: State changed from up to down
    2016-10-31T14:00:08.267802+00:00 heroku[web.1]: Stopping all processes with SIGTERM
    2016-10-31T14:00:09.009402+00:00 heroku[web.1]: Process exited with status 143
    2016-10-31T16:34:38.691494+00:00 heroku[web.1]: State changed from down to starting
    2016-10-31T16:34:40.170397+00:00 heroku[web.1]: Starting process with command `node index.js`
    2016-10-31T16:34:42.503141+00:00 app[web.1]: Server started, listening on39519
    2016-10-31T16:34:43.875418+00:00 heroku[web.1]: State changed from starting to up

2016-10-31 heroku[router]: at=error code=H12
 desc="Request timeout" method=GET path="/" host=xxxx-xxxx-xxxx.herokuapp.com 
request_id=20f79d56-4e51-4ace-af50-9b332e9778a1 fwd="my IP address here" dyno=web.1 connect=0ms 
service=30000ms status=503 bytes=0