()
| 600 | } |
| 601 | |
| 602 | async function stopDaemon(): Promise<void> { |
| 603 | const layout = resolveDaemonLayout(); |
| 604 | switch (layout.platform) { |
| 605 | case 'darwin': |
| 606 | assertFileExists(layout.launchdPlistPath, 'launchd plist'); |
| 607 | await runCommand('launchctl', ['bootout', `gui/${process.getuid?.() ?? 0}`, layout.launchdPlistPath!], { allowFailure: true }); |
| 608 | return; |
| 609 | case 'linux': |
| 610 | await runCommand('systemctl', ['--user', 'stop', layout.systemdServiceName!]); |
| 611 | return; |
| 612 | case 'win32': |
| 613 | await runPowerShellScript([ |
| 614 | '$ErrorActionPreference = "Stop"', |
| 615 | `$TaskName = ${toPowerShellString(layout.windowsTaskName ?? WINDOWS_TASK_NAME)}`, |
| 616 | 'Stop-ScheduledTask -TaskName $TaskName -ErrorAction SilentlyContinue', |
| 617 | ].join('\n')); |
| 618 | return; |
| 619 | default: |
| 620 | throw new Error(`Unsupported daemon platform: ${layout.platform}`); |
| 621 | } |
| 622 | } |
| 623 | |
| 624 | async function restartDaemon(): Promise<void> { |
| 625 | const layout = resolveDaemonLayout(); |
no test coverage detected