dev / templates / bot / test / worker.js
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
// Stub worker for the respawn-race test (worker-respawn.test.mjs).
// join-worker-room derives its fork target as <dirname(argv[1])>/worker.js;
// under `node --test` argv[1] is the test file, so this stub sits beside it.
// It appends one line to <job.dataDir>/spawn.log so the test can count forks,
// then crashes (behavior "crash") or waits for SIGTERM.
import { appendFileSync, mkdirSync } from "node:fs";
import { join } from "node:path";

const job = JSON.parse(process.argv[2]);
mkdirSync(job.dataDir, { recursive: true });
appendFileSync(join(job.dataDir, "spawn.log"), `spawn ${Date.now()}\n`);
if (job.behavior === "crash") process.exit(1);
setInterval(() => {}, 1 << 30); // stay alive until SIGTERM

static mirror of HEAD · about · clone: git clone https://git.ardegazu.ro/dev.git