Handling Mongo connection errors and starting bcoin once the db connects
This commit is contained in:
parent
63f60d06eb
commit
045c53accb
@ -12,6 +12,8 @@ const config = {
|
|||||||
uri: 'mongodb://localhost/bitcore',
|
uri: 'mongodb://localhost/bitcore',
|
||||||
options: {
|
options: {
|
||||||
useMongoClient: true,
|
useMongoClient: true,
|
||||||
|
socketTimeoutMS: 0,
|
||||||
|
connectTimeoutMS: 0
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
api: {
|
api: {
|
||||||
|
|||||||
4
index.js
4
index.js
@ -14,4 +14,6 @@ Api.listen(config.api.port, () => {
|
|||||||
'listening on port 3000');
|
'listening on port 3000');
|
||||||
});
|
});
|
||||||
|
|
||||||
node.start();
|
db.connection.once('open', function() {
|
||||||
|
node.start();
|
||||||
|
});
|
||||||
|
|||||||
@ -1,3 +1,10 @@
|
|||||||
const mongoose = require('mongoose');
|
const mongoose = require('mongoose');
|
||||||
|
const logger = require('../logger');
|
||||||
|
|
||||||
|
mongoose.connection.on('error', (err) => {
|
||||||
|
logger.log('error',
|
||||||
|
`Failed to connect to Mongo Database
|
||||||
|
${err}`);
|
||||||
|
});
|
||||||
|
|
||||||
module.exports = mongoose;
|
module.exports = mongoose;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user