(port: number, commandName: string, boot = false)
| 2897 | }; |
| 2898 | |
| 2899 | const installService = (port: number, commandName: string, boot = false) => |
| 2900 | Effect.gen(function* () { |
| 2901 | const command = `${cliPrefix} ${commandName}`; |
| 2902 | if (isDevMode) { |
| 2903 | return yield* Effect.fail( |
| 2904 | new Error( |
| 2905 | [ |
| 2906 | `\`${command}\` requires the compiled \`executor\` binary so the OS can run it directly.`, |
| 2907 | `In a dev checkout, run \`${cliPrefix} daemon run --foreground\` instead.`, |
| 2908 | ].join("\n"), |
| 2909 | ), |
| 2910 | ); |
| 2911 | } |
| 2912 | |
| 2913 | const backend = getServiceBackend(); |
| 2914 | |
| 2915 | // `--boot` only means something on Windows (a boot/S4U Scheduled Task). The |
| 2916 | // launchd/systemd backends silently ignore the descriptor field, so warn |
| 2917 | // rather than let a macOS/Linux caller believe it took effect. |
| 2918 | if (boot && backend.platform !== "win32") { |
| 2919 | console.warn( |
| 2920 | `Note: --boot is a Windows-only option and has no effect on ${process.platform}; installing the standard login-based service.`, |
| 2921 | ); |
| 2922 | } |
| 2923 | |
| 2924 | if (!backend.automated) { |
| 2925 | // Unsupported platforms surface their manual steps via the install error. |
| 2926 | yield* backend.install({ |
| 2927 | executablePath: process.execPath, |
| 2928 | port, |
| 2929 | version: CLI_VERSION, |
| 2930 | boot, |
| 2931 | }); |
| 2932 | return; |
| 2933 | } |
| 2934 | |
| 2935 | const status = yield* backend.status(); |
| 2936 | const active = yield* readActiveLocalServerManifest().pipe(Effect.orElseSucceed(() => null)); |
| 2937 | const plan = planServiceInstall({ |
| 2938 | registered: status.registered, |
| 2939 | running: status.running, |
| 2940 | activeKind: active?.kind ?? null, |
| 2941 | activePid: active?.pid ?? null, |
| 2942 | servicePid: status.pid, |
| 2943 | activeVersion: active?.owner.version ?? null, |
| 2944 | activeExecutablePath: active?.owner.executablePath ?? null, |
| 2945 | activePort: active ? portFromOrigin(active.connection.origin) : null, |
| 2946 | requestedPort: port, |
| 2947 | currentVersion: CLI_VERSION, |
| 2948 | currentExecutablePath: process.execPath, |
| 2949 | }); |
| 2950 | |
| 2951 | if (plan === "noop") { |
| 2952 | const where = active ? ` at ${active.connection.origin} (pid ${active.pid})` : ""; |
| 2953 | console.log(`Executor background service is already running${where}.`); |
| 2954 | console.log(`Open it in your browser, already signed in, with: ${cliPrefix} web`); |
| 2955 | return; |
| 2956 | } |
no test coverage detected