我想在Heroku上开发一个MEAN堆栈应用程序,然而,它失败并给我一些错误并要求我检查日志。我的应用程序在localhost上工作正常,这里是app github链接:https://github.com/zichenma/blackboard我不知道发生了什么。有人可以帮我这个吗?非常感谢你的进步!
2016-10-26T19:25:04.437140+00:00 app[web.1]: # Unstable releases are available for preview/testing only.
2016-10-26T19:25:04.437211+00:00 app[web.1]: #
2016-10-26T19:25:04.437255+00:00 app[web.1]: ##############################################################
2016-10-26T19:25:04.437283+00:00 app[web.1]:
2016-10-26T19:25:04.489004+00:00 app[web.1]: Wed, 26 Oct 2016 19:25:04 GMT express-session deprecated undefined resave option; provide resave option at server.js:33:9
2016-10-26T19:25:04.490059+00:00 app[web.1]: Wed, 26 Oct 2016 19:25:04 GMT express-session deprecated undefined saveUninitialized option; provide saveUninitialized option at server.js:33:9
2016-10-26T19:25:04.490153+00:00 app[web.1]: Warning: connect.session() MemoryStore is not
2016-10-26T19:25:04.490155+00:00 app[web.1]: designed for a production environment, as it will leak
2016-10-26T19:25:04.490156+00:00 app[web.1]: memory, and will not scale past a single process.
2016-10-26T19:25:04.588917+00:00 app[web.1]: { [MongoError: auth failed] name: 'MongoError', ok: 0, errmsg: 'auth failed', code: 18 }
2016-10-26T19:26:02.387104+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2016-10-26T19:26:02.387104+00:00 heroku[web.1]: Stopping process with SIGKILL
2016-10-26T19:26:02.512694+00:00 heroku[web.1]: Process exited with status 137
2016-10-26T19:26:02.584450+00:00 heroku[web.1]: State changed from starting to crashed
2016-10-26T19:26:02.585639+00:00 heroku[web.1]: State changed from crashed to starting
2016-10-26T19:26:04.361960+00:00 heroku[web.1]: Starting process with command `node server.js`
2016-10-26T19:26:07.234279+00:00 app[web.1]: { [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' }
2016-10-26T19:26:07.235703+00:00 app[web.1]: js-bson: Failed to load c++ bson extension, using pure JS version
2016-10-26T19:26:07.434343+00:00 app[web.1]:
2016-10-26T19:26:07.434389+00:00 app[web.1]: ##############################################################
2016-10-26T19:26:07.434444+00:00 app[web.1]: #
2016-10-26T19:26:07.434485+00:00 app[web.1]: # !!! MONGOOSE WARNING !!!
2016-10-26T19:26:07.434524+00:00 app[web.1]: #
2016-10-26T19:26:07.434564+00:00 app[web.1]: # This is an UNSTABLE release of Mongoose.
2016-10-26T19:26:07.434643+00:00 app[web.1]: # DO NOT run this in production.
2016-10-26T19:26:07.434602+00:00 app[web.1]: # Unstable releases are available for preview/testing only.
2016-10-26T19:26:07.434688+00:00 app[web.1]: #
2016-10-26T19:26:07.434729+00:00 app[web.1]: ##############################################################
2016-10-26T19:26:07.434769+00:00 app[web.1]:
2016-10-26T19:26:07.531910+00:00 app[web.1]: Wed, 26 Oct 2016 19:26:07 GMT express-session deprecated undefined resave option; provide resave option at server.js:33:9
2016-10-26T19:26:07.533899+00:00 app[web.1]: Wed, 26 Oct 2016 19:26:07 GMT express-session deprecated undefined saveUninitialized option; provide saveUninitialized option at server.js:33:9
2016-10-26T19:26:07.630763+00:00 app[web.1]: { [MongoError: auth failed] name: 'MongoError', ok: 0, errmsg: 'auth failed', code: 18 }
2016-10-26T19:26:07.538978+00:00 app[web.1]: Warning: connect.session() MemoryStore is not
2016-10-26T19:26:07.538983+00:00 app[web.1]: designed for a production environment, as it will leak
2016-10-26T19:26:07.538984+00:00 app[web.1]: memory, and will not scale past a single process.
2016-10-26T19:26:24.587674+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/" host=zichenblackboard.herokuapp.com request_id=a2d7df9b-7e2f-467d-8d56-0952a7445c19 fwd="129.10.9.121" dyno= connect= service= status=503 bytes=
2016-10-26T19:27:04.738904+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2016-10-26T19:27:04.739029+00:00 heroku[web.1]: Stopping process with SIGKILL
2016-10-26T19:27:04.940692+00:00 heroku[web.1]: Process exited with status 137
2016-10-26T19:27:04.973605+00:00 heroku[web.1]: State changed from starting to crashed
2016-10-26T19:27:06.449518+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=zichenblackboard.herokuapp.com request_id=9855f356-0e8c-4263-81fc-772b1072cc45 fwd="129.10.9.121" dyno= connect= service= status=503 bytes=
2016-10-26T19:27:06.620739+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=zichenblackboard.herokuapp.com request_id=cb5da5c7-15c1-4d81-9a7b-ab9aaf6c05d4 fwd="129.10.9.121" dyno= connect= service= status=503 bytes=
2016-10-26T19:27:07.049617+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=zichenblackboard.herokuapp.com request_id=f19e3ed2-a72c-48f3-a42b-734d86d7ce67 fwd="129.10.9.121" dyno= connect= service= status=503 bytes=
2016-10-26T19:27:24.589248+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=zichenblackboard.herokuapp.com request_id=af99564e-dce2-4676-9969-124862c9f36b fwd="129.10.9.121" dyno= connect= service= status=503 bytes=
2016-10-26T19:27:24.969275+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=zichenblackboard.herokuapp.com request_id=6a853ff5-831d-4069-8f60-a1570f15795b fwd="129.10.9.121" dyno= connect= service= status=503 bytes=
2016-10-26T19:27:42.412204+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=zichenblackboard.herokuapp.com request_id=b7a68539-d9b5-485f-8c47-81d78995be2f fwd="129.10.9.121" dyno= connect= service= status=503 bytes=
2016-10-26T19:27:42.781982+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=zichenblackboard.herokuapp.com request_id=621881ff-990b-425f-b31a-e7a990ddbbe5 fwd="129.10.9.121" dyno= connect= service= status=503 bytes=
2016-10-26T19:32:24.969477+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=zichenblackboard.herokuapp.com request_id=5429d788-e362-4769-8d10-f830856ca24a fwd="129.10.9.121" dyno= connect= service= status=503 bytes=
2016-10-26T19:32:25.256442+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=zichenblackboard.herokuapp.com request_id=bbd4c7b8-a8e3-461e-8630-8cd2da7cd58f fwd="129.10.9.121" dyno= connect= service= status=503 bytes=
2016-10-26T19:37:35.811641+00:00 heroku[api]: Deploy e841e2b by mazichen1984@gmail.com
2016-10-26T19:37:35.811736+00:00 heroku[api]: Release v7 created by mazichen1984@gmail.com
2016-10-26T19:37:36.054933+00:00 heroku[slug-compiler]: Slug compilation started
2016-10-26T19:37:36.054944+00:00 heroku[slug-compiler]: Slug compilation finished
2016-10-26T19:37:36.492951+00:00 heroku[web.1]: State changed from crashed to starting
2016-10-26T19:37:37.808413+00:00 heroku[web.1]: Starting process with command `node server.js`
2016-10-26T19:37:39.901939+00:00 app[web.1]: js-bson: Failed to load c++ bson extension, using pure JS version
2016-10-26T19:37:39.900937+00:00 app[web.1]: { [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' }
2016-10-26T19:37:40.050266+00:00 app[web.1]:
2016-10-26T19:37:40.050286+00:00 app[web.1]: ##############################################################
2016-10-26T19:37:40.050325+00:00 app[web.1]: #
2016-10-26T19:37:40.050354+00:00 app[web.1]: # !!! MONGOOSE WARNING !!!
2016-10-26T19:37:40.050392+00:00 app[web.1]: #
2016-10-26T19:37:40.050418+00:00 app[web.1]: # This is an UNSTABLE release of Mongoose.
2016-10-26T19:37:40.050447+00:00 app[web.1]: # DO NOT run this in production.
2016-10-26T19:37:40.050445+00:00 app[web.1]: # Unstable releases are available for preview/testing only.
2016-10-26T19:37:40.050466+00:00 app[web.1]: #
2016-10-26T19:37:40.050515+00:00 app[web.1]:
2016-10-26T19:37:40.050493+00:00 app[web.1]: ##############################################################
2016-10-26T19:37:40.094020+00:00 app[web.1]: Wed, 26 Oct 2016 19:37:40 GMT express-session deprecated undefined resave option; provide resave option at server.js:33:9
2016-10-26T19:37:40.094930+00:00 app[web.1]: Wed, 26 Oct 2016 19:37:40 GMT express-session deprecated undefined saveUninitialized option; provide saveUninitialized option at server.js:33:9
2016-10-26T19:37:40.095011+00:00 app[web.1]: Warning: connect.session() MemoryStore is not
2016-10-26T19:37:40.095012+00:00 app[web.1]: designed for a production environment, as it will leak
2016-10-26T19:37:40.095012+00:00 app[web.1]: memory, and will not scale past a single process.
2016-10-26T19:37:40.134038+00:00 app[web.1]: [Error: failed to connect to [localhost:27017]]
2016-10-26T19:37:40.252494+00:00 heroku[web.1]: State changed from starting to crashed
2016-10-26T19:37:40.253488+00:00 heroku[web.1]: State changed from crashed to starting
2016-10-26T19:37:40.234424+00:00 heroku[web.1]: Process exited with status 0
2016-10-26T19:37:41.790766+00:00 heroku[web.1]: Starting process with command `node server.js`
2016-10-26T19:37:44.134867+00:00 app[web.1]: { [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' }
2016-10-26T19:37:44.135992+00:00 app[web.1]: js-bson: Failed to load c++ bson extension, using pure JS version
2016-10-26T19:37:44.501677+00:00 app[web.1]:
2016-10-26T19:37:44.501724+00:00 app[web.1]: ##############################################################
2016-10-26T19:37:44.501769+00:00 app[web.1]: #
2016-10-26T19:37:44.501809+00:00 app[web.1]: # !!! MONGOOSE WARNING !!!
2016-10-26T19:37:44.501846+00:00 app[web.1]: #
2016-10-26T19:37:44.501886+00:00 app[web.1]: # This is an UNSTABLE release of Mongoose.
2016-10-26T19:37:44.501922+00:00 app[web.1]: # Unstable releases are available for preview/testing only.
2016-10-26T19:37:44.501959+00:00 app[web.1]: # DO NOT run this in production.
2016-10-26T19:37:44.502010+00:00 app[web.1]: #
2016-10-26T19:37:44.502042+00:00 app[web.1]: ##############################################################
2016-10-26T19:37:44.502060+00:00 app[web.1]:
2016-10-26T19:37:44.608668+00:00 app[web.1]: Wed, 26 Oct 2016 19:37:44 GMT express-session deprecated undefined resave option; provide resave option at server.js:33:9
2016-10-26T19:37:44.609658+00:00 app[web.1]: Wed, 26 Oct 2016 19:37:44 GMT express-session deprecated undefined saveUninitialized option; provide saveUninitialized option at server.js:33:9
2016-10-26T19:37:44.609748+00:00 app[web.1]: memory, and will not scale past a single process.
2016-10-26T19:37:44.609745+00:00 app[web.1]: Warning: connect.session() MemoryStore is not
2016-10-26T19:37:44.638489+00:00 app[web.1]: [Error: failed to connect to [localhost:27017]]
2016-10-26T19:37:44.609747+00:00 app[web.1]: designed for a production environment, as it will leak
2016-10-26T19:37:44.730255+00:00 heroku[web.1]: State changed from starting to crashed
2016-10-26T19:37:44.718868+00:00 heroku[web.1]: Process exited with status 0
2016-10-26T19:37:48.073902+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=zichenblackboard.herokuapp.com request_id=e8562216-4639-4014-b497-0f976fe8d463 fwd="129.10.9.121" dyno= connect= service= status=503 bytes=
2016-10-26T19:37:48.424557+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=zichenblackboard.herokuapp.com request_id=70192eaa-2e82-4037-a7a3-43d32e4c8c54 fwd="129.10.9.121" dyno= connect= service= status=503 bytes=
我的server.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 session = require('express-session');
var passport = require('passport');
//initialize mongoose schemas
require('./models/models');
require('./models/course');
var index = require('./routes/index');
var api = require('./routes/api');
var authenticate = require('./routes/authenticate')(passport);
var mongoose = require('mongoose'); //add for Mongo support
mongoose.connect(process.env.MONGOLAB_URI ||'mongodb://localhost:27017/courseManager', function (err) {
if(err){
console.error(err)
}else {
console.log("connected");
}
}); //connect to Mongo
var app = express();
// 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(session({
secret: 'keyboard cat'
}));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use(passport.initialize());
app.use(passport.session());
app.use('/',index);
app.use('/auth', authenticate);
app.use('/api', api);
// catch 404 and forward to error handler
app.use(function(req, res, next) {
var err = new Error('Not Found');
err.status = 404;
next(err);
});
//// Initialize Passport
var initPassport = require('./passport-init');
initPassport(passport);
// 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: {}
});
});
module.exports = app;
答案 0 :(得分:0)
现在您的Procfile
正在指示Heroku的业务流程使用node server.js
启动流程。将Procfile
中的该行更改为web: npm start
或web: bin/www
。