diff --git a/apps/master/package.json b/apps/master/package.json index d27f3fda..b44e29e9 100644 --- a/apps/master/package.json +++ b/apps/master/package.json @@ -14,6 +14,7 @@ "debug": "^4.3.4", "ioredis": "^5.0.1", "mongodb": "^5.1.0", + "p-event": "^6.0.0", "source-map-support": "^0.5.21" }, "devDependencies": { diff --git a/apps/master/src/index.ts b/apps/master/src/index.ts index 52005da7..d9c4d20f 100644 --- a/apps/master/src/index.ts +++ b/apps/master/src/index.ts @@ -10,6 +10,7 @@ import { Redis } from "ioredis"; import calculatePresenceUsage from "./util/calculatePresenceUsage.js"; import updateScience from "./util/updateScience.js"; +import { pEvent } from "p-event"; if (process.env.NODE_ENV !== "production") (await import("dotenv")).config({ path: "../../../.env" }); @@ -39,11 +40,8 @@ export const redis = new Redis({ debug.enable("API-Master*"); -mainLog("Connecting to MongoDB..."); -await mongo.connect(); -mainLog("Connecting to Redis..."); -await redis.connect(); - +mainLog("Connecting to MongoDB and Redis..."); +await Promise.all([mongo.connect(), pEvent(redis, "connect")]); mainLog("Connected!"); await Promise.all([updateScience(), calculatePresenceUsage()]); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 50ccbe02..44b2df85 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -28,6 +28,9 @@ importers: mongodb: specifier: ^5.1.0 version: 5.1.0 + p-event: + specifier: ^6.0.0 + version: 6.0.0 source-map-support: specifier: ^0.5.21 version: 0.5.21 @@ -3187,6 +3190,13 @@ packages: p-timeout: 3.2.0 dev: false + /p-event@6.0.0: + resolution: {integrity: sha512-Xbfxd0CfZmHLGKXH32k1JKjQYX6Rkv0UtQdaFJ8OyNcf+c0oWCeXHc1C4CX/IESZLmcvfPa5aFIO/vCr5gqtag==} + engines: {node: '>=16.17'} + dependencies: + p-timeout: 6.1.2 + dev: false + /p-finally@1.0.0: resolution: {integrity: sha512-LICb2p9CB7FS+0eR1oqWnHhp0FljGLZCWBE9aix0Uye9W8LTQPwMTYVGWQWIw9RdQiDg4+epXQODwIYJtSJaow==} engines: {node: '>=4'} @@ -3204,6 +3214,11 @@ packages: p-finally: 1.0.0 dev: false + /p-timeout@6.1.2: + resolution: {integrity: sha512-UbD77BuZ9Bc9aABo74gfXhNvzC9Tx7SxtHSh1fxvx3jTLLYvmVhiQZZrJzqqU0jKbN32kb5VOKiLEQI/3bIjgQ==} + engines: {node: '>=14.16'} + dev: false + /package-json@6.5.0: resolution: {integrity: sha512-k3bdm2n25tkyxcjSKzB5x8kfVxlMdgsbPr0GkZcwHsLpba6cBjqCt1KlcChKEvxHIcTB1FVMuwoijZ26xex5MQ==} engines: {node: '>=8'}