From 6f3e341e896102230140fbcdebbbd9a37df618e5 Mon Sep 17 00:00:00 2001 From: mei23 Date: Wed, 22 Aug 2018 08:46:31 +0900 Subject: [PATCH] Fix DB connectivity check --- src/index.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 086e665679..470699eab9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -14,6 +14,7 @@ import * as portscanner from 'portscanner'; import isRoot = require('is-root'); import Xev from 'xev'; import * as program from 'commander'; +import mongo from './db/mongodb'; import Logger from './misc/logger'; import ProgressBar from './misc/cli/progressbar'; @@ -158,8 +159,13 @@ function checkMongoDb(config: Config) { 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'); + + mongo.then(() => { + mongoDBLogger.succ('Connectivity confirmed'); + }) + .catch(err => { + mongoDBLogger.error(err.message); + }); } function spawnWorkers(limit: number) {