flush redis on startup and init subredis
This commit is contained in:
@@ -1,16 +1,27 @@
|
|||||||
import { initRedis } from "./redis.js";
|
import { getRoomIDs } from "../api/livedata/livedata.repository.js";
|
||||||
|
import { initRedis, initSubRedis } from "../redis/redis.js";
|
||||||
import * as mqtt from "./mqtt.js";
|
import * as mqtt from "./mqtt.js";
|
||||||
import { cleanupWorker } from "./transition.js";
|
import { cleanupWorker } from "./transition.js";
|
||||||
|
|
||||||
export async function bootstrap() {
|
export async function bootstrap() {
|
||||||
try {
|
try {
|
||||||
await initRedis();
|
const redis = await initRedis();
|
||||||
|
|
||||||
|
await redis.flushDb();
|
||||||
|
console.log(`[!] Flushed Redis.`);
|
||||||
|
|
||||||
|
const rooms = await getRoomIDs();
|
||||||
|
for (const { id } of rooms)
|
||||||
|
await redis.set(`room:${id}`, 0);
|
||||||
|
|
||||||
|
await initSubRedis();
|
||||||
await mqtt.start();
|
await mqtt.start();
|
||||||
|
|
||||||
cleanupWorker();
|
cleanupWorker();
|
||||||
|
|
||||||
console.log("Core started.");
|
console.log("[!] Core started.");
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
console.log("Bootstrap failed:", err.message);
|
console.log("[!] Bootstrap failed:", err.message);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user