MCPcopy Create free account
hub / github.com/cloudflare/computer / startComputerd

Function startComputerd

packages/computerd/src/cli/computerd.test.ts:357–390  ·  view source on GitHub ↗
({
  port,
  mountPoint,
  env = {},
}: {
  port: number;
  mountPoint: string;
  env?: Record<string, string>;
})

Source from the content-addressed store, hash-verified

355});
356
357async function startComputerd({
358 port,
359 mountPoint,
360 env = {},
361}: {
362 port: number;
363 mountPoint: string;
364 env?: Record<string, string>;
365}) {
366 const child = spawn(cliPath, {
367 cwd: packageRoot,
368 env: { ...process.env, MOUNT_POINT: mountPoint, PORT: String(port), ...env },
369 stdio: ["ignore", "pipe", "pipe"],
370 });
371
372 let stdout = "";
373 let stderr = "";
374 child.stdout.setEncoding("utf8");
375 child.stderr.setEncoding("utf8");
376 child.stdout.on("data", (chunk) => {
377 stdout += chunk;
378 });
379 child.stderr.on("data", (chunk) => {
380 stderr += chunk;
381 });
382
383 onTestFinished(async () => {
384 await stopProcess(child);
385 await fs.rm(mountPoint, { recursive: true, force: true });
386 });
387
388 await waitForHTTPOK(`http://127.0.0.1:${port}/health`, child, () => stderr || stdout);
389 return child;
390}
391
392function getAvailablePort() {
393 return new Promise((resolve, reject) => {

Callers 1

computerd.test.tsFile · 0.85

Calls 3

stopProcessFunction · 0.85
waitForHTTPOKFunction · 0.85
rmMethod · 0.65

Tested by

no test coverage detected