MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / installService

Function installService

apps/cli/src/main.ts:3016–3134  ·  view source on GitHub ↗
(port: number, commandName: string, boot = false)

Source from the content-addressed store, hash-verified

3014};
3015
3016const installService = (port: number, commandName: string, boot = false) =>
3017 Effect.gen(function* () {
3018 const command = `${cliPrefix} ${commandName}`;
3019 if (isDevMode) {
3020 return yield* Effect.fail(
3021 new Error(
3022 [
3023 `\`${command}\` requires the compiled \`executor\` binary so the OS can run it directly.`,
3024 `In a dev checkout, run \`${cliPrefix} daemon run --foreground\` instead.`,
3025 ].join("\n"),
3026 ),
3027 );
3028 }
3029
3030 const backend = getServiceBackend();
3031
3032 // `--boot` only means something on Windows (a boot/S4U Scheduled Task). The
3033 // launchd/systemd backends silently ignore the descriptor field, so warn
3034 // rather than let a macOS/Linux caller believe it took effect.
3035 if (boot && backend.platform !== "win32") {
3036 console.warn(
3037 `Note: --boot is a Windows-only option and has no effect on ${process.platform}; installing the standard login-based service.`,
3038 );
3039 }
3040
3041 if (!backend.automated) {
3042 // Unsupported platforms surface their manual steps via the install error.
3043 yield* backend.install({
3044 executablePath: process.execPath,
3045 port,
3046 version: CLI_VERSION,
3047 boot,
3048 });
3049 return;
3050 }
3051
3052 const status = yield* backend.status();
3053 const active = yield* readActiveLocalServerManifest().pipe(Effect.orElseSucceed(() => null));
3054 const plan = planServiceInstall({
3055 registered: status.registered,
3056 running: status.running,
3057 activeKind: active?.kind ?? null,
3058 activePid: active?.pid ?? null,
3059 servicePid: status.pid,
3060 activeVersion: active?.owner.version ?? null,
3061 activeExecutablePath: active?.owner.executablePath ?? null,
3062 activePort: active ? portFromOrigin(active.connection.origin) : null,
3063 requestedPort: port,
3064 currentVersion: CLI_VERSION,
3065 currentExecutablePath: process.execPath,
3066 });
3067
3068 if (plan === "noop") {
3069 const where = active ? ` at ${active.connection.origin} (pid ${active.pid})` : "";
3070 console.log(`Executor background service is already running${where}.`);
3071 console.log(`Open it in your browser, already signed in, with: ${cliPrefix} web`);
3072 return;
3073 }

Callers 1

main.tsFile · 0.85

Calls 12

getServiceBackendFunction · 0.90
planServiceInstallFunction · 0.90
resolveExecutorDataDirFunction · 0.90
waitForReachableFunction · 0.90
portFromOriginFunction · 0.85
supervisedServiceOriginFunction · 0.85
serviceManagerNameFunction · 0.85
warnMethod · 0.80
logMethod · 0.80

Tested by

no test coverage detected