MCPcopy Index your code
hub / github.com/coder/coder / startAgentWithCommand

Function startAgentWithCommand

site/e2e/helpers.ts:516–542  ·  view source on GitHub ↗
(
	page: Page,
	token: string,
	command: string,
	...args: string[]
)

Source from the content-addressed store, hash-verified

514};
515
516export const startAgentWithCommand = async (
517 page: Page,
518 token: string,
519 command: string,
520 ...args: string[]
521): Promise<ChildProcess> => {
522 const cp = spawn(command, [...args, "agent", "--no-reap"], {
523 env: {
524 ...process.env,
525 CODER_AGENT_URL: `http://localhost:${coderPort}`,
526 CODER_AGENT_TOKEN: token,
527 CODER_AGENT_PPROF_ADDRESS: `127.0.0.1:${agentPProfPort}`,
528 CODER_AGENT_PROMETHEUS_ADDRESS: `127.0.0.1:${prometheusPort}`,
529 },
530 });
531 cp.stdout.on("data", (data: Buffer) => {
532 console.info(`[agent][stdout] ${data.toString().replace(/\n$/g, "")}`);
533 });
534 cp.stderr.on("data", (data: Buffer) => {
535 console.info(`[agent][stderr] ${data.toString().replace(/\n$/g, "")}`);
536 });
537
538 await page
539 .getByTestId("agent-status-ready")
540 .waitFor({ state: "visible", timeout: 15_000 });
541 return cp;
542};
543
544export const stopAgent = async (cp: ChildProcess) => {
545 // The command `kill` is used to terminate an agent started as a standalone binary.

Callers 2

startAgentFunction · 0.85

Calls 1

infoMethod · 0.80

Tested by

no test coverage detected