die if cant connect to mongodb

This commit is contained in:
Matias Alejo Garcia 2015-04-28 11:00:50 -03:00
parent 784e3d956c
commit 25cbf5ddbd
1 changed files with 9 additions and 3 deletions

12
bws.js
View File

@ -34,19 +34,21 @@ var start = function(cb) {
if (config.cluster) {
server = sticky(clusterInstances, function() {
ExpressApp.start(config, function(err, app) {
if (err) return cb(err);
var server = config.https ? serverModule.createServer(serverOpts, app) :
serverModule.Server(app);
WsApp.start(server, config);
return server;
});
});
return cb(server);
return cb(null, server);
} else {
ExpressApp.start(config, function(err, app) {
if (err) return cb(err);
server = config.https ? serverModule.createServer(serverOpts, app) :
serverModule.Server(app);
WsApp.start(server, config);
return cb(server);
return cb(null, server);
});
};
};
@ -54,7 +56,11 @@ var start = function(cb) {
if (config.cluster && !config.lockOpts.lockerServer)
throw 'When running in cluster mode, locker server need to be configured';
start(function(server) {
start(function(err, server) {
if (err) {
console.log('Could not start BWS:', err);
process.exit(0);
}
server.listen(port, function(err) {
if (err) console.log('ERROR: ', err);
log.info('Bitcore Wallet Service running on port ' + port);