()
| 575 | } |
| 576 | |
| 577 | async 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 | |
| 602 | async function stopDaemon(): Promise<void> { |
| 603 | const layout = resolveDaemonLayout(); |
no test coverage detected