MCPcopy
hub / github.com/callstack/agent-device / startDaemon

Function startDaemon

src/daemon/client/daemon-client-lifecycle.ts:382–405  ·  view source on GitHub ↗
(settings: DaemonClientSettings)

Source from the content-addressed store, hash-verified

380}
381
382function startDaemon(settings: DaemonClientSettings): DaemonStartupLaunch {
383 const launchSpec = resolveDaemonLaunchSpec();
384 const args = launchSpec.useSrc
385 ? ['--experimental-strip-types', launchSpec.srcPath]
386 : [launchSpec.distPath];
387 const env = {
388 ...process.env,
389 AGENT_DEVICE_STATE_DIR: settings.paths.baseDir,
390 AGENT_DEVICE_DAEMON_SERVER_MODE: settings.serverMode,
391 };
392
393 fs.mkdirSync(settings.paths.baseDir, { recursive: true });
394 const stdoutFd = fs.openSync(settings.paths.logPath, 'a');
395 const stderrFd = fs.openSync(settings.paths.logPath, 'a');
396 try {
397 return runCmdDetachedMonitored(process.execPath, args, {
398 env,
399 stdio: ['ignore', stdoutFd, stderrFd],
400 });
401 } finally {
402 fs.closeSync(stdoutFd);
403 fs.closeSync(stderrFd);
404 }
405}
406
407type DaemonLaunchSpec = {
408 root: string;

Callers 1

startLocalDaemonFunction · 0.85

Calls 2

runCmdDetachedMonitoredFunction · 0.90
resolveDaemonLaunchSpecFunction · 0.85

Tested by

no test coverage detected