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

Function installService

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

Source from the content-addressed store, hash-verified

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

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