MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / setup

Function setup

e2e/setup/selfhost.globalsetup.ts:23–53  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

21 : resolve(RUNS_DIR, "selfhost", "server-logs", "boot.log");
22
23export default async function setup(): Promise<(() => Promise<void>) | void> {
24 if (process.env.E2E_SELFHOST_URL) {
25 await waitForHttp(process.env.E2E_SELFHOST_URL);
26 return;
27 }
28
29 if (bootLogFile) mkdirSync(resolve(bootLogFile, ".."), { recursive: true });
30
31 // Claim a free port (preferred block first, walk forward past squatters),
32 // boot, and retry on EADDRINUSE (a Linux-CI ephemeral socket can grab a
33 // claimed port between probe and bind). The claimed port is published via env
34 // so the test workers derive the same URL; the imported targets/selfhost
35 // constants were computed BEFORE the claim — don't use them for ports here.
36 const { teardown } = await claimAndBoot(
37 [{ envVar: "E2E_SELFHOST_PORT", offset: 4, label: "selfhost vite dev" }],
38 async (ports) => {
39 const port = ports.E2E_SELFHOST_PORT!;
40 // Fresh data dir per suite run — hermetic; in-suite isolation comes from
41 // fresh identities, not resets (bootSelfhost wipes it).
42 const procs = await bootSelfhost({
43 port,
44 webBaseUrl: `http://localhost:${port}`,
45 admin: SELFHOST_ADMIN,
46 logFile: bootLogFile,
47 });
48 return { teardown: procs.teardown, value: procs };
49 },
50 { label: "selfhost" },
51 );
52 return teardown;
53}

Callers

nothing calls this directly

Calls 4

waitForHttpFunction · 0.90
claimAndBootFunction · 0.90
bootSelfhostFunction · 0.90
resolveFunction · 0.50

Tested by

no test coverage detected