Use a single MongoDB client

This commit is contained in:
Zaid Abdulla committed 2020-11-18 00:01:41 -08:00
1 parent bd55d6f512
commit a9b0e3a1f7
9 files changed
+197 -287

No files matched your search

+5 -7
View File
@@ -23,7 +23,6 @@ import * as cluster from "../lib/cluster";
import * as server from "../lib/server";
import { listener } from "../lib/fs";
import * as db from "../lib/db";
import * as cache from "../lib/cache";
import { version as VERSION } from "../package.json";
logger.init("fs", VERSION);
@@ -33,11 +32,9 @@ const SERVICE_PORT = config.get("FS_PORT") as number;
function exitWorkerGracefully(): void {
setTimeout(exitWorkerUngracefully, 5000).unref();
Promise.all([
db.disconnect(),
cache.disconnect(),
cluster.worker.disconnect(),
]).catch(exitWorkerUngracefully);
Promise.all([db.disconnect(), cluster.worker.disconnect()]).catch(
exitWorkerUngracefully
);
}
function exitWorkerUngracefully(): void {
@@ -100,7 +97,8 @@ if (!cluster.worker) {
listener(req, res);
};
const initPromise = Promise.all([db.connect(), cache.connect()])
const initPromise = db
.connect()
.then(() => {
server.start(options, _listener);
})