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

Function bootSelfhost

e2e/setup/selfhost.boot.ts:33–86  ·  view source on GitHub ↗
(options: SelfhostBootOptions)

Source from the content-addressed store, hash-verified

31}
32
33export const bootSelfhost = async (options: SelfhostBootOptions): Promise<BootedProcesses> => {
34 const dataDir = options.dataDir ?? resolve(selfhostDir, ".e2e-data");
35 if (options.fresh ?? true) rmSync(dataDir, { recursive: true, force: true });
36
37 const procs = bootProcesses(
38 [
39 {
40 cmd: "bunx",
41 args: [
42 "--bun",
43 "vite",
44 "dev",
45 "--port",
46 String(options.port),
47 "--strictPort",
48 ...(options.host ? ["--host", options.host] : []),
49 ],
50 cwd: selfhostDir,
51 env: {
52 EXECUTOR_DATA_DIR: dataDir,
53 BETTER_AUTH_SECRET: "executor-selfhost-e2e-secret-0123456789",
54 EXECUTOR_BOOTSTRAP_ADMIN_EMAIL: options.admin.email,
55 EXECUTOR_BOOTSTRAP_ADMIN_PASSWORD: options.admin.password,
56 EXECUTOR_WEB_BASE_URL: options.webBaseUrl,
57 // The harness boots loopback MCP/OAuth test servers and points the
58 // instance at them; the hosted SSRF guard would otherwise block
59 // outbound probes/dials to localhost. Hermetic test instance only.
60 EXECUTOR_ALLOW_LOCAL_NETWORK: "true",
61 ...(options.sandboxTimeoutMs !== undefined
62 ? { EXECUTOR_SANDBOX_TIMEOUT_MS: String(options.sandboxTimeoutMs) }
63 : {}),
64 ...(options.mcpSessionIdleTtlMs !== undefined
65 ? { EXECUTOR_MCP_SESSION_IDLE_TTL_MS: String(options.mcpSessionIdleTtlMs) }
66 : {}),
67 },
68 logFile: options.logFile,
69 },
70 ],
71 { label: "selfhost" },
72 );
73
74 try {
75 // Probe via `localhost`, not 127.0.0.1 — without --host, vite binds the
76 // resolver's first answer for localhost (::1 on macOS), so the IPv4
77 // loopback literal never answers.
78 await waitForBoot(procs, (signal) =>
79 waitForHttp(`http://localhost:${options.port}`, { signal }),
80 );
81 } catch (error) {
82 await procs.teardown();
83 throw error;
84 }
85 return procs;
86};

Callers 3

setupFunction · 0.90
runFunction · 0.85

Calls 4

bootProcessesFunction · 0.90
waitForBootFunction · 0.90
waitForHttpFunction · 0.90
resolveFunction · 0.50

Tested by

no test coverage detected