()
| 622 | } |
| 623 | |
| 624 | async function restartDaemon(): Promise<void> { |
| 625 | const layout = resolveDaemonLayout(); |
| 626 | switch (layout.platform) { |
| 627 | case 'darwin': |
| 628 | assertFileExists(layout.launchdPlistPath, 'launchd plist'); |
| 629 | await runCommand('launchctl', ['bootout', `gui/${process.getuid?.() ?? 0}`, layout.launchdPlistPath!], { allowFailure: true }); |
| 630 | await runCommand('launchctl', ['bootstrap', `gui/${process.getuid?.() ?? 0}`, layout.launchdPlistPath!]); |
| 631 | await runCommand('launchctl', ['enable', `gui/${process.getuid?.() ?? 0}/${layout.launchdLabel!}`]); |
| 632 | await runCommand('launchctl', ['kickstart', '-k', `gui/${process.getuid?.() ?? 0}/${layout.launchdLabel!}`]); |
| 633 | return; |
| 634 | case 'linux': |
| 635 | await runCommand('systemctl', ['--user', 'restart', layout.systemdServiceName!]); |
| 636 | return; |
| 637 | case 'win32': |
| 638 | await runPowerShellScript([ |
| 639 | '$ErrorActionPreference = "Stop"', |
| 640 | `$TaskName = ${toPowerShellString(layout.windowsTaskName ?? WINDOWS_TASK_NAME)}`, |
| 641 | 'Stop-ScheduledTask -TaskName $TaskName -ErrorAction SilentlyContinue', |
| 642 | 'Start-ScheduledTask -TaskName $TaskName', |
| 643 | ].join('\n')); |
| 644 | return; |
| 645 | default: |
| 646 | throw new Error(`Unsupported daemon platform: ${layout.platform}`); |
| 647 | } |
| 648 | } |
| 649 | |
| 650 | async function statusDaemon(): Promise<void> { |
| 651 | const layout = resolveDaemonLayout(); |
no test coverage detected