MCPcopy Create free account
hub / github.com/Gan-Xing/CodexBridge / startDaemon

Function startDaemon

packages/codex-native-api/src/daemon_manager.ts:577–600  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

575}
576
577async function startDaemon(): Promise<void> {
578 const layout = resolveDaemonLayout();
579 switch (layout.platform) {
580 case 'darwin':
581 assertFileExists(layout.launchdPlistPath, 'launchd plist');
582 await runCommand('launchctl', ['bootstrap', `gui/${process.getuid?.() ?? 0}`, layout.launchdPlistPath!], { allowFailure: true });
583 await runCommand('launchctl', ['enable', `gui/${process.getuid?.() ?? 0}/${layout.launchdLabel!}`]);
584 await runCommand('launchctl', ['kickstart', '-k', `gui/${process.getuid?.() ?? 0}/${layout.launchdLabel!}`]);
585 return;
586 case 'linux':
587 assertFileExists(layout.systemdUnitPath, 'systemd user unit');
588 await runCommand('systemctl', ['--user', 'start', layout.systemdServiceName!]);
589 return;
590 case 'win32':
591 await runPowerShellScript([
592 '$ErrorActionPreference = "Stop"',
593 `$TaskName = ${toPowerShellString(layout.windowsTaskName ?? WINDOWS_TASK_NAME)}`,
594 'Start-ScheduledTask -TaskName $TaskName',
595 ].join('\n'));
596 return;
597 default:
598 throw new Error(`Unsupported daemon platform: ${layout.platform}`);
599 }
600}
601
602async function stopDaemon(): Promise<void> {
603 const layout = resolveDaemonLayout();

Callers 1

runDaemonCommandFunction · 0.85

Calls 5

resolveDaemonLayoutFunction · 0.85
assertFileExistsFunction · 0.85
runCommandFunction · 0.85
runPowerShellScriptFunction · 0.85
toPowerShellStringFunction · 0.85

Tested by

no test coverage detected