flush redis on startup and init subredis

This commit is contained in:
Kostas Drakontidis
2026-05-25 05:55:04 +03:00
parent 66ab3fa6ca
commit c2b947a197
+15 -4
View File
@@ -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 { cleanupWorker } from "./transition.js";
export async function bootstrap() {
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();
cleanupWorker();
console.log("Core started.");
console.log("[!] Core started.");
} catch (err: any) {
console.log("Bootstrap failed:", err.message);
console.log("[!] Bootstrap failed:", err.message);
process.exit(1);
}
}