(port: number, commandName: string, boot = false)
| 2818 | }; |
| 2819 | |
| 2820 | const installService = (port: number, commandName: string, boot = false) => |
| 2821 | Effect.gen(function* () { |
| 2822 | const command = `${cliPrefix} ${commandName}`; |
| 2823 | if (isDevMode) { |
| 2824 | return yield* Effect.fail( |
| 2825 | new Error( |
| 2826 | [ |
| 2827 | `\`${command}\` requires the compiled \`executor\` binary so the OS can run it directly.`, |
| 2828 | `In a dev checkout, run \`${cliPrefix} daemon run --foreground\` instead.`, |
| 2829 | ].join("\n"), |
| 2830 | ), |
| 2831 | ); |
| 2832 | } |
| 2833 | |
| 2834 | const backend = getServiceBackend(); |
| 2835 | |
| 2836 | // `--boot` only means something on Windows (a boot/S4U Scheduled Task). The |
| 2837 | // launchd/systemd backends silently ignore the descriptor field, so warn |
| 2838 | // rather than let a macOS/Linux caller believe it took effect. |
| 2839 | if (boot && backend.platform !== "win32") { |
| 2840 | console.warn( |
| 2841 | `Note: --boot is a Windows-only option and has no effect on ${process.platform}; installing the standard login-based service.`, |
| 2842 | ); |
| 2843 | } |
| 2844 | |
| 2845 | if (!backend.automated) { |
| 2846 | // Unsupported platforms surface their manual steps via the install error. |
| 2847 | yield* backend.install({ |
| 2848 | executablePath: process.execPath, |
| 2849 | port, |
| 2850 | version: CLI_VERSION, |
| 2851 | boot, |
| 2852 | }); |
| 2853 | return; |
| 2854 | } |
| 2855 | |
| 2856 | const status = yield* backend.status(); |
| 2857 | const active = yield* readActiveLocalServerManifest().pipe(Effect.orElseSucceed(() => null)); |
| 2858 | const plan = planServiceInstall({ |
| 2859 | registered: status.registered, |
| 2860 | running: status.running, |
| 2861 | activeKind: active?.kind ?? null, |
| 2862 | activePid: active?.pid ?? null, |
| 2863 | servicePid: status.pid, |
| 2864 | activeVersion: active?.owner.version ?? null, |
| 2865 | activeExecutablePath: active?.owner.executablePath ?? null, |
| 2866 | activePort: active ? portFromOrigin(active.connection.origin) : null, |
| 2867 | requestedPort: port, |
| 2868 | currentVersion: CLI_VERSION, |
| 2869 | currentExecutablePath: process.execPath, |
| 2870 | }); |
| 2871 | |
| 2872 | if (plan === "noop") { |
| 2873 | const where = active ? ` at ${active.connection.origin} (pid ${active.pid})` : ""; |
| 2874 | console.log(`Executor background service is already running${where}.`); |
| 2875 | console.log(`Open it in your browser, already signed in, with: ${cliPrefix} web`); |
| 2876 | return; |
| 2877 | } |
no test coverage detected