Harden gameplay timing and map loading

This commit is contained in:
2026-10-05 15:15:35 +05:00
parent 8b31891776
commit dcc3779262
36 changed files with 1050 additions and 205 deletions

View File

@@ -1,13 +1,16 @@
import { spawn } from "node:child_process";
import { existsSync } from "node:fs";
import { validateRuntime } from "./runtime-config.mjs";
if (existsSync(".env.local")) process.loadEnvFile(".env.local");
const dev = process.argv[2] === "dev";
const { workerHeap } = validateRuntime(process.env, { production: !dev });
const children = [];
let stopping = false;
function run(args) {
const c = spawn(process.execPath, args, {
stdio: "inherit",
env: process.env,
windowsHide: true,
});
children.push(c);
c.on("exit", (code) => {
@@ -34,10 +37,9 @@ run([
"--hostname",
process.env.MINEGEO_HOST || "127.0.0.1",
]);
const workerHeap = Number(process.env.MINEGEO_WORKER_HEAP_MB || 4096);
if (!Number.isInteger(workerHeap) || workerHeap < 512 || workerHeap > 32768) {
console.error("MINEGEO_WORKER_HEAP_MB must be an integer between 512 and 32768.");
stop(1);
} else {
run([`--max-old-space-size=${workerHeap}`, "--import", "tsx", "worker/main.ts"]);
}
run([
`--max-old-space-size=${workerHeap}`,
"--import",
"tsx",
"worker/main.ts",
]);