MCPcopy Create free account
hub / github.com/AmazingAng/PolyWorld / register

Function register

src/instrumentation.ts:35–77  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

33}
34
35export async function register() {
36 if (process.env.NEXT_RUNTIME === "nodejs") {
37 if (globalThis.__polyworldRuntimeStarted) {
38 return;
39 }
40
41 validateEnv();
42
43 const { startSyncLoop, stopSyncLoop } = await import("./lib/sync");
44 startSyncLoop();
45 const { startNewsSyncLoop, stopNewsSyncLoop } = await import("./lib/newsSync");
46 startNewsSyncLoop();
47 const { startSmartMoneySync, stopSmartMoneySync } = await import("./lib/smartMoneySync");
48 startSmartMoneySync();
49 const { startTweetsSyncLoop, stopTweetsSyncLoop } = await import("./lib/tweetsSync");
50 startTweetsSyncLoop();
51 const { startResolutionSyncLoop, stopResolutionSyncLoop } = await import("./lib/resolutionSync");
52 startResolutionSyncLoop();
53 globalThis.__polyworldRuntimeStarted = true;
54
55 if (!globalThis.__polyworldShutdownBound) {
56 const shutdown = async () => {
57 console.info("[shutdown] Graceful shutdown initiated...");
58 stopSyncLoop();
59 stopNewsSyncLoop();
60 stopSmartMoneySync();
61 stopTweetsSyncLoop();
62 stopResolutionSyncLoop();
63 globalThis.__polyworldRuntimeStarted = false;
64
65 const { closeDb } = await import("./lib/db");
66 closeDb();
67
68 console.info("[shutdown] Cleanup complete, exiting.");
69 process.exit(0);
70 };
71
72 process.on("SIGTERM", shutdown);
73 process.on("SIGINT", shutdown);
74 globalThis.__polyworldShutdownBound = true;
75 }
76 }
77}

Callers

nothing calls this directly

Calls 6

validateEnvFunction · 0.85
startSyncLoopFunction · 0.85
startNewsSyncLoopFunction · 0.85
startSmartMoneySyncFunction · 0.85
startTweetsSyncLoopFunction · 0.85
startResolutionSyncLoopFunction · 0.85

Tested by

no test coverage detected