MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / startBot

Function startBot

src/cli/bot-process.ts:40–53  ·  view source on GitHub ↗
(cwd: string)

Source from the content-addressed store, hash-verified

38}
39
40export async function startBot(cwd: string): Promise<{ ok: boolean; message: string }> {
41 const cur = await botStatus();
42 if (cur.running) return { ok: false, message: `Bot already running (pid ${cur.pid}).` };
43 try {
44 await fs.mkdir(QODEX_HOME, { recursive: true });
45 const child = spawn(resolveCliPath(), ['bot'], { cwd, detached: true, stdio: 'ignore' });
46 child.unref();
47 if (!child.pid) return { ok: false, message: 'Could not spawn the bot process.' };
48 await fs.writeFile(pidFilePath(), String(child.pid), 'utf-8');
49 return { ok: true, message: `Bot started (pid ${child.pid}). It needs a token + allowlist in config to actually connect.` };
50 } catch (e: any) {
51 return { ok: false, message: `Failed to start bot: ${e?.message ?? e}` };
52 }
53}
54
55export async function stopBot(): Promise<{ ok: boolean; message: string }> {
56 const cur = await botStatus();

Callers 1

dispatchActionFunction · 0.85

Calls 3

botStatusFunction · 0.85
pidFilePathFunction · 0.85
resolveCliPathFunction · 0.70

Tested by

no test coverage detected