summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/index.ts13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/index.ts b/src/index.ts
index 7ed606ecfc..086e665679 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -146,9 +146,22 @@ async function init(): Promise<Config> {
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