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

Function installService

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

Source from the content-addressed store, hash-verified

2897};
2898
2899const installService = (port: number, commandName: string, boot = false) =>
2900 Effect.gen(function* () {
2901 const command = `${cliPrefix} ${commandName}`;
2902 if (isDevMode) {
2903 return yield* Effect.fail(
2904 new Error(
2905 [
2906 `\`${command}\` requires the compiled \`executor\` binary so the OS can run it directly.`,
2907 `In a dev checkout, run \`${cliPrefix} daemon run --foreground\` instead.`,
2908 ].join("\n"),
2909 ),
2910 );
2911 }
2912
2913 const backend = getServiceBackend();
2914
2915 // `--boot` only means something on Windows (a boot/S4U Scheduled Task). The
2916 // launchd/systemd backends silently ignore the descriptor field, so warn
2917 // rather than let a macOS/Linux caller believe it took effect.
2918 if (boot && backend.platform !== "win32") {
2919 console.warn(
2920 `Note: --boot is a Windows-only option and has no effect on ${process.platform}; installing the standard login-based service.`,
2921 );
2922 }
2923
2924 if (!backend.automated) {
2925 // Unsupported platforms surface their manual steps via the install error.
2926 yield* backend.install({
2927 executablePath: process.execPath,
2928 port,
2929 version: CLI_VERSION,
2930 boot,
2931 });
2932 return;
2933 }
2934
2935 const status = yield* backend.status();
2936 const active = yield* readActiveLocalServerManifest().pipe(Effect.orElseSucceed(() => null));
2937 const plan = planServiceInstall({
2938 registered: status.registered,
2939 running: status.running,
2940 activeKind: active?.kind ?? null,
2941 activePid: active?.pid ?? null,
2942 servicePid: status.pid,
2943 activeVersion: active?.owner.version ?? null,
2944 activeExecutablePath: active?.owner.executablePath ?? null,
2945 activePort: active ? portFromOrigin(active.connection.origin) : null,
2946 requestedPort: port,
2947 currentVersion: CLI_VERSION,
2948 currentExecutablePath: process.execPath,
2949 });
2950
2951 if (plan === "noop") {
2952 const where = active ? ` at ${active.connection.origin} (pid ${active.pid})` : "";
2953 console.log(`Executor background service is already running${where}.`);
2954 console.log(`Open it in your browser, already signed in, with: ${cliPrefix} web`);
2955 return;
2956 }

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