Skip to content

Commit e531d88

Browse files
committedDec 27, 2023
fix(master): connect redis correctly
1 parent f7a5c76 commit e531d88

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed
 

‎apps/master/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"debug": "^4.3.4",
1515
"ioredis": "^5.0.1",
1616
"mongodb": "^5.1.0",
17+
"p-event": "^6.0.0",
1718
"source-map-support": "^0.5.21"
1819
},
1920
"devDependencies": {

‎apps/master/src/index.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { Redis } from "ioredis";
1010

1111
import calculatePresenceUsage from "./util/calculatePresenceUsage.js";
1212
import updateScience from "./util/updateScience.js";
13+
import { pEvent } from "p-event";
1314

1415
if (process.env.NODE_ENV !== "production")
1516
(await import("dotenv")).config({ path: "../../../.env" });
@@ -39,11 +40,8 @@ export const redis = new Redis({
3940

4041
debug.enable("API-Master*");
4142

42-
mainLog("Connecting to MongoDB...");
43-
await mongo.connect();
44-
mainLog("Connecting to Redis...");
45-
await redis.connect();
46-
43+
mainLog("Connecting to MongoDB and Redis...");
44+
await Promise.all([mongo.connect(), pEvent(redis, "connect")]);
4745
mainLog("Connected!");
4846

4947
await Promise.all([updateScience(), calculatePresenceUsage()]);

‎pnpm-lock.yaml

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)