Reputation: 834
This is my Heroku log when I deploy my app the build is successful but the app crashes with code 503
2015-07-04T12:17:49.485610+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=mycityweather.herokuapp.com request_id=37e7fe0c-63fe-4f96-8d17-857df8cfc0c2 fwd="150.129.28.90" dyno= connect= service= status=503 bytes=
2015-07-04T12:17:50.040740+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=mycityweather.herok uapp.com request_id=fc18d77b-8ff5-4a7a-ae4c-5be89d17365b fwd="150.129.28.90" dyno= connect= service= status=503 bytes=
What is the reason for that error? And what is the solution for it?
This is my main app.js
var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var cluster =require("cluster");
var cpusNum=require('os').cpus().length;
var routes = require('./routes/index');
var users = require('./routes/users');
var app = express();
var port=process.env.PORT || 3000;
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
// uncomment after placing your favicon in /public
app.use(favicon(__dirname + '/public/favicon.ico'));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use('/', routes);
app.use('/users', users);
// catch 404 and forward to error handler
app.use(function(req, res, next) {
var err = new Error('Not Found');
err.status = 404;
next(err);
});
// error handlers
// development error handler
// will print stacktrace
if (app.get('env') === 'development') {
app.use(function(err, req, res, next) {
res.status(err.status || 500);
res.render('error', {
message: err.message,
error: err
});
});
}
// production error handler
// no stacktraces leaked to user
app.use(function(err, req, res, next) {
res.status(err.status || 500);
res.render('error', {
message: err.message,
error: {}
});
});
if(cluster.isMaster)
{
//fork Workers
for(var i=0;i<cpusNum;i++)
{
cluster.fork();
}
cluster.on('exit',function(worker,code,signal){
console.log("Worker with "+ worker.process.pid + 'died');
});
}
else{
app.listen(port,function(){
console.log('Server started on port '+port);
});
}
module.exports = app;
This is my main entry point file and there is no proper error message that will show me exact cause for iy.
Upvotes: 0
Views: 302
Reputation: 834
Got it there was error in npm versions on server side and my local machine.
Upvotes: 1