From 4bf3827b7380f6ee8a2d3e12b34d319c7f52e2c3 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 22 Aug 2018 09:12:37 +0900 Subject: [PATCH] Revert "#2387" This reverts commit 3cad494404ad0e2df2a4d42f2934640f402d1412. --- src/index.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/index.ts b/src/index.ts index 7ed606ecf..086e66567 100644 --- a/src/index.ts +++ b/src/index.ts @@ -146,9 +146,22 @@ async function init(): Promise { process.exit(1); } + // Try to connect to MongoDB + checkMongoDb(config); + return config; } +function checkMongoDb(config: Config) { + const mongoDBLogger = new Logger('MongoDB'); + const u = config.mongodb.user ? encodeURIComponent(config.mongodb.user) : null; + const p = config.mongodb.pass ? encodeURIComponent(config.mongodb.pass) : null; + const uri = `mongodb://${u && p ? `${u}:****@` : ''}${config.mongodb.host}:${config.mongodb.port}/${config.mongodb.db}`; + mongoDBLogger.info(`Connecting to ${uri}`); + require('./db/mongodb'); + mongoDBLogger.succ('Connectivity confirmed'); +} + function spawnWorkers(limit: number) { return new Promise(res => { // Count the machine's CPUs