(port: number, commandName: string, boot = false)
| 2866 | }; |
| 2867 | |
| 2868 | const installService = (port: number, commandName: string, boot = false) => |
| 2869 | Effect.gen(function* () { |
| 2870 | const command = `${cliPrefix} ${commandName}`; |
| 2871 | if (isDevMode) { |
| 2872 | return yield* Effect.fail( |
| 2873 | new Error( |
| 2874 | [ |
| 2875 | `\`${command}\` requires the compiled \`executor\` binary so the OS can run it directly.`, |
| 2876 | `In a dev checkout, run \`${cliPrefix} daemon run --foreground\` instead.`, |
| 2877 | ].join("\n"), |
| 2878 | ), |
| 2879 | ); |
| 2880 | } |
| 2881 | |
| 2882 | const backend = getServiceBackend(); |
| 2883 | |
| 2884 | // `--boot` only means something on Windows (a boot/S4U Scheduled Task). The |
| 2885 | // launchd/systemd backends silently ignore the descriptor field, so warn |
| 2886 | // rather than let a macOS/Linux caller believe it took effect. |
| 2887 | if (boot && backend.platform !== "win32") { |
| 2888 | console.warn( |
| 2889 | `Note: --boot is a Windows-only option and has no effect on ${process.platform}; installing the standard login-based service.`, |
| 2890 | ); |
| 2891 | } |
| 2892 | |
| 2893 | if (!backend.automated) { |
| 2894 | // Unsupported platforms surface their manual steps via the install error. |
| 2895 | yield* backend.install({ |
| 2896 | executablePath: process.execPath, |
| 2897 | port, |
| 2898 | version: CLI_VERSION, |
| 2899 | boot, |
| 2900 | }); |
| 2901 | return; |
| 2902 | } |
| 2903 | |
| 2904 | const status = yield* backend.status(); |
| 2905 | const active = yield* readActiveLocalServerManifest().pipe(Effect.orElseSucceed(() => null)); |
| 2906 | const plan = planServiceInstall({ |
| 2907 | registered: status.registered, |
| 2908 | running: status.running, |
| 2909 | activeKind: active?.kind ?? null, |
| 2910 | activePid: active?.pid ?? null, |
| 2911 | servicePid: status.pid, |
| 2912 | activeVersion: active?.owner.version ?? null, |
| 2913 | activeExecutablePath: active?.owner.executablePath ?? null, |
| 2914 | activePort: active ? portFromOrigin(active.connection.origin) : null, |
| 2915 | requestedPort: port, |
| 2916 | currentVersion: CLI_VERSION, |
| 2917 | currentExecutablePath: process.execPath, |
| 2918 | }); |
| 2919 | |
| 2920 | if (plan === "noop") { |
| 2921 | const where = active ? ` at ${active.connection.origin} (pid ${active.pid})` : ""; |
| 2922 | console.log(`Executor background service is already running${where}.`); |
| 2923 | console.log(`Open it in your browser, already signed in, with: ${cliPrefix} web`); |
| 2924 | return; |
| 2925 | } |
no test coverage detected