Use a single MongoDB client
This commit is contained in:
1 parent
bd55d6f512
commit
a9b0e3a1f7
9 files changed
+197
-287
No files matched your search
@@ -24,7 +24,6 @@ import * as server from "../lib/server";
|
||||
import * as cwmp from "../lib/cwmp";
|
||||
import * as db from "../lib/db";
|
||||
import * as extensions from "../lib/extensions";
|
||||
import * as cache from "../lib/cache";
|
||||
import { version as VERSION } from "../package.json";
|
||||
|
||||
logger.init("cwmp", VERSION);
|
||||
@@ -36,7 +35,6 @@ function exitWorkerGracefully(): void {
|
||||
setTimeout(exitWorkerUngracefully, 5000).unref();
|
||||
Promise.all([
|
||||
db.disconnect(),
|
||||
cache.disconnect(),
|
||||
extensions.killAll(),
|
||||
cluster.worker.disconnect(),
|
||||
]).catch(exitWorkerUngracefully);
|
||||
@@ -99,7 +97,8 @@ if (!cluster.worker) {
|
||||
server.stop().then(exitWorkerGracefully).catch(exitWorkerUngracefully);
|
||||
});
|
||||
|
||||
const initPromise = Promise.all([db.connect(), cache.connect()])
|
||||
const initPromise = db
|
||||
.connect()
|
||||
.then(() => {
|
||||
server.start(options, cwmp.listener);
|
||||
})
|
||||
|
||||
+5
-7
@@ -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);
|
||||
})
|
||||
|
||||
+2
-3
@@ -24,7 +24,6 @@ import * as server from "../lib/server";
|
||||
import { listener } from "../lib/nbi";
|
||||
import * as db from "../lib/db";
|
||||
import * as extensions from "../lib/extensions";
|
||||
import * as cache from "../lib/cache";
|
||||
import { version as VERSION } from "../package.json";
|
||||
|
||||
logger.init("nbi", VERSION);
|
||||
@@ -36,7 +35,6 @@ function exitWorkerGracefully(): void {
|
||||
setTimeout(exitWorkerUngracefully, 5000).unref();
|
||||
Promise.all([
|
||||
db.disconnect(),
|
||||
cache.disconnect(),
|
||||
extensions.killAll(),
|
||||
cluster.worker.disconnect(),
|
||||
]).catch(exitWorkerUngracefully);
|
||||
@@ -104,7 +102,8 @@ if (!cluster.worker) {
|
||||
listener(req, res);
|
||||
};
|
||||
|
||||
const initPromise = Promise.all([db.connect(), cache.connect()])
|
||||
const initPromise = db
|
||||
.connect()
|
||||
.then(() => {
|
||||
server.start(options, _listener);
|
||||
})
|
||||
|
||||
+3
-6
@@ -23,9 +23,7 @@ import * as cluster from "../lib/cluster";
|
||||
import * as server from "../lib/server";
|
||||
import { listener } from "../lib/ui";
|
||||
import * as extensions from "../lib/extensions";
|
||||
import * as db from "../lib/ui/db";
|
||||
import * as db2 from "../lib/db";
|
||||
import * as cache from "../lib/cache";
|
||||
import * as db from "../lib/db";
|
||||
import { version as VERSION } from "../package.json";
|
||||
|
||||
logger.init("ui", VERSION);
|
||||
@@ -37,8 +35,6 @@ function exitWorkerGracefully(): void {
|
||||
setTimeout(exitWorkerUngracefully, 5000).unref();
|
||||
Promise.all([
|
||||
db.disconnect(),
|
||||
db2.disconnect(),
|
||||
cache.disconnect(),
|
||||
extensions.killAll(),
|
||||
cluster.worker.disconnect(),
|
||||
]).catch(exitWorkerUngracefully);
|
||||
@@ -106,7 +102,8 @@ if (!cluster.worker) {
|
||||
listener(req, res);
|
||||
};
|
||||
|
||||
const initPromise = Promise.all([db2.connect(), cache.connect()])
|
||||
const initPromise = db
|
||||
.connect()
|
||||
.then(() => {
|
||||
server.start(options, _listener);
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user