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

Function installService

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

Source from the content-addressed store, hash-verified

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

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