refactor: ♻️ Use node:cluster instead of Web Workers

This commit is contained in:
Jesse Wierzbinski 2024-08-23 18:43:13 +02:00 committed by April John
parent 3279f3098b
commit 0a1c2b8cb3
3 changed files with 18 additions and 18 deletions

View file

@ -35,17 +35,12 @@ export default class Start extends BaseCommand<typeof Start> {
const numCpus = flags["all-threads"] ? os.cpus().length : flags.threads;
// Check if index is a JS or TS file (depending on the environment)
const index = (await Bun.file("index.ts").exists())
? "index.ts"
: "index.js";
// Resolves the path to the main module
const resolved = import.meta.resolve("../../index");
await import("../../setup");
process.env.NUM_CPUS = String(numCpus);
process.env.SILENT = flags.silent ? "true" : "false";
for (let i = 0; i < numCpus; i++) {
new Worker(index, {
type: "module",
});
}
await import(resolved);
}
}