Basic MEAN app runs locally but times out / won't load on Heroku

时间:2017-04-10 00:06:51

标签: node.js angular heroku mlab

First time building with nodejs + Angular 2 + mLab.com. Runs locally. Trying deploying but the app times out when launched. See Error report at the bottom.

project/package.json

{
  "name": "task",
  "version": "1.0.0",
  "description": "",
  "main": "server.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "body-parser": "^1.17.1",
    "ejs": "^2.5.6",
    "express": "^4.15.2",
    "mongojs": "^2.4.0"
  },
  "engines":{
    "node": "4.2.6"
  }
}

project/client/package.json

{
  "name": "angular-quickstart",
  "version": "1.0.0",
  "scripts": {
    "start": "tsc && concurrently \"tsc -w\" \"lite-server\" ",
    "lite": "lite-server",
    "postinstall": "typings install",
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "typings": "typings"
  },
  "licenses": [
    {
      "type": "MIT",
      "url": "https://github.com/angular/angular.io/blob/master/LICENSE"
    }
  ],
  "dependencies": {
    "@angular/common": "~2.0.2",
    "@angular/compiler": "~2.0.2",
    "@angular/core": "~2.0.2",
    "@angular/forms": "~2.0.2",
    "@angular/http": "~2.0.2",
    "@angular/platform-browser": "~2.0.2",
    "@angular/platform-browser-dynamic": "~2.0.2",
    "@angular/router": "~3.0.2",
    "@angular/upgrade": "~2.0.2",
    "angular-in-memory-web-api": "~0.1.5",
    "bootstrap": "^3.3.7",
    "core-js": "^2.4.1",
    "reflect-metadata": "^0.1.8",
    "rxjs": "5.0.0-beta.12",
    "systemjs": "0.19.39",
    "zone.js": "^0.6.25"
  },
  "devDependencies": {
    "concurrently": "^3.0.0",
    "lite-server": "^2.2.2",
    "typescript": "^2.0.3",
    "typings":"^1.4.0"
  },
  "engines" : {
  "node": "4.2.6",
  "npm": "4.4.4"
  }
}

Procfile

web: node server.js

server.js

var express = require('express');
var path = require('path');
var bodyParser = require('body-parser');
var index = require('./routes/index');
var tasks = require('./routes/tasks');
var port = 2000;
var app = express();
//View Engine
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
app.engine('html', require('ejs').renderFile);
// Set Static Folder
app.use(express.static(path.join(__dirname, 'client')));
// Body Parser MW
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));
app.use('/', index);
app.use('/api', tasks);

app.listen(port, function(){
    console.log('Server started on port '+port);
});

heroku app error log:

2017-04-09T23:57:55.243053+00:00 app[web.1]: Server started on port 2000
2017-04-09T23:58:52.575687+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2017-04-09T23:58:52.576051+00:00 heroku[web.1]: Stopping process with SIGKILL
2017-04-09T23:58:52.700011+00:00 heroku[web.1]: State changed from starting to crashed
2017-04-09T23:58:52.701201+00:00 heroku[web.1]: State changed from crashed to starting
2017-04-09T23:58:52.685745+00:00 heroku[web.1]: Process exited with status 137
2017-04-09T23:58:55.768561+00:00 heroku[web.1]: Starting process with command `node server.js`
2017-04-09T23:58:58.747375+00:00 app[web.1]: Server started on port 2000
2017-04-09T23:59:16.589649+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/" host=whispering-wildwood-87042.herokuapp.com request_id=f69eecc6-5877-465e-aa13-48a0d8d884ec fwd="24.186.93.231" dyno= connect= service= status=503 bytes= protocol=https

0 个答案:

没有答案