feat: remove clustering to improve caching
This commit is contained in:
+8
-21
@@ -1,26 +1,13 @@
|
||||
import cluster from "node:cluster";
|
||||
import process from "node:process";
|
||||
import { AssetManager } from "./lib/assets";
|
||||
|
||||
declare global {
|
||||
var forked: boolean;
|
||||
}
|
||||
queueMicrotask(async () => {
|
||||
const assets = new AssetManager();
|
||||
assets.getMissingAssets();
|
||||
|
||||
if (cluster.isPrimary) {
|
||||
if (!globalThis.forked) {
|
||||
for (let i = 0; i < 2; i++) cluster.fork();
|
||||
globalThis.forked = true;
|
||||
}
|
||||
|
||||
queueMicrotask(async () => {
|
||||
const assets = new AssetManager();
|
||||
setInterval(() => {
|
||||
assets.getMissingAssets();
|
||||
|
||||
setInterval(() => {
|
||||
assets.getMissingAssets();
|
||||
}, 86400000); // refresh assets every 24 hours
|
||||
});
|
||||
} else {
|
||||
await import("./server");
|
||||
console.log(`Worker ${process.pid} started`);
|
||||
}
|
||||
}, 86400000); // refresh assets every 24 hours
|
||||
});
|
||||
await import("./server");
|
||||
console.log(`Worker ${process.pid} started`);
|
||||
|
||||
Reference in New Issue
Block a user