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

Function installService

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

Source from the content-addressed store, hash-verified

2926};
2927
2928const installService = (port: number, commandName: string, boot = false) =>
2929 Effect.gen(function* () {
2930 const command = `${cliPrefix} ${commandName}`;
2931 if (isDevMode) {
2932 return yield* Effect.fail(
2933 new Error(
2934 [
2935 `\`${command}\` requires the compiled \`executor\` binary so the OS can run it directly.`,
2936 `In a dev checkout, run \`${cliPrefix} daemon run --foreground\` instead.`,
2937 ].join("\n"),
2938 ),
2939 );
2940 }
2941
2942 const backend = getServiceBackend();
2943
2944 // `--boot` only means something on Windows (a boot/S4U Scheduled Task). The
2945 // launchd/systemd backends silently ignore the descriptor field, so warn
2946 // rather than let a macOS/Linux caller believe it took effect.
2947 if (boot && backend.platform !== "win32") {
2948 console.warn(
2949 `Note: --boot is a Windows-only option and has no effect on ${process.platform}; installing the standard login-based service.`,
2950 );
2951 }
2952
2953 if (!backend.automated) {
2954 // Unsupported platforms surface their manual steps via the install error.
2955 yield* backend.install({
2956 executablePath: process.execPath,
2957 port,
2958 version: CLI_VERSION,
2959 boot,
2960 });
2961 return;
2962 }
2963
2964 const status = yield* backend.status();
2965 const active = yield* readActiveLocalServerManifest().pipe(Effect.orElseSucceed(() => null));
2966 const plan = planServiceInstall({
2967 registered: status.registered,
2968 running: status.running,
2969 activeKind: active?.kind ?? null,
2970 activePid: active?.pid ?? null,
2971 servicePid: status.pid,
2972 activeVersion: active?.owner.version ?? null,
2973 activeExecutablePath: active?.owner.executablePath ?? null,
2974 activePort: active ? portFromOrigin(active.connection.origin) : null,
2975 requestedPort: port,
2976 currentVersion: CLI_VERSION,
2977 currentExecutablePath: process.execPath,
2978 });
2979
2980 if (plan === "noop") {
2981 const where = active ? ` at ${active.connection.origin} (pid ${active.pid})` : "";
2982 console.log(`Executor background service is already running${where}.`);
2983 console.log(`Open it in your browser, already signed in, with: ${cliPrefix} web`);
2984 return;
2985 }

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