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

Function installService

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

Source from the content-addressed store, hash-verified

3043};
3044
3045const installService = (port: number, commandName: string, boot = false) =>
3046 Effect.gen(function* () {
3047 const command = `${cliPrefix} ${commandName}`;
3048 if (isDevMode) {
3049 return yield* Effect.fail(
3050 new Error(
3051 [
3052 `\`${command}\` requires the compiled \`executor\` binary so the OS can run it directly.`,
3053 `In a dev checkout, run \`${cliPrefix} daemon run --foreground\` instead.`,
3054 ].join("\n"),
3055 ),
3056 );
3057 }
3058
3059 const backend = getServiceBackend();
3060
3061 // `--boot` only means something on Windows (a boot/S4U Scheduled Task). The
3062 // launchd/systemd backends silently ignore the descriptor field, so warn
3063 // rather than let a macOS/Linux caller believe it took effect.
3064 if (boot && backend.platform !== "win32") {
3065 console.warn(
3066 `Note: --boot is a Windows-only option and has no effect on ${process.platform}; installing the standard login-based service.`,
3067 );
3068 }
3069
3070 if (!backend.automated) {
3071 // Unsupported platforms surface their manual steps via the install error.
3072 yield* backend.install({
3073 executablePath: process.execPath,
3074 port,
3075 version: CLI_VERSION,
3076 boot,
3077 });
3078 return;
3079 }
3080
3081 const status = yield* backend.status();
3082 const active = yield* readActiveLocalServerManifest().pipe(Effect.orElseSucceed(() => null));
3083 const plan = planServiceInstall({
3084 registered: status.registered,
3085 running: status.running,
3086 activeKind: active?.kind ?? null,
3087 activePid: active?.pid ?? null,
3088 servicePid: status.pid,
3089 activeVersion: active?.owner.version ?? null,
3090 activeExecutablePath: active?.owner.executablePath ?? null,
3091 activePort: active ? portFromOrigin(active.connection.origin) : null,
3092 requestedPort: port,
3093 currentVersion: CLI_VERSION,
3094 currentExecutablePath: process.execPath,
3095 });
3096
3097 if (plan === "noop") {
3098 const where = active ? ` at ${active.connection.origin} (pid ${active.pid})` : "";
3099 console.log(`Executor background service is already running${where}.`);
3100 console.log(`Open it in your browser, already signed in, with: ${cliPrefix} web`);
3101 return;
3102 }

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