(settings: DaemonClientSettings)
| 380 | } |
| 381 | |
| 382 | function 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 | |
| 407 | type DaemonLaunchSpec = { |
| 408 | root: string; |
no test coverage detected