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

Function installService

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

Source from the content-addressed store, hash-verified

2866};
2867
2868const installService = (port: number, commandName: string, boot = false) =>
2869 Effect.gen(function* () {
2870 const command = `${cliPrefix} ${commandName}`;
2871 if (isDevMode) {
2872 return yield* Effect.fail(
2873 new Error(
2874 [
2875 `\`${command}\` requires the compiled \`executor\` binary so the OS can run it directly.`,
2876 `In a dev checkout, run \`${cliPrefix} daemon run --foreground\` instead.`,
2877 ].join("\n"),
2878 ),
2879 );
2880 }
2881
2882 const backend = getServiceBackend();
2883
2884 // `--boot` only means something on Windows (a boot/S4U Scheduled Task). The
2885 // launchd/systemd backends silently ignore the descriptor field, so warn
2886 // rather than let a macOS/Linux caller believe it took effect.
2887 if (boot && backend.platform !== "win32") {
2888 console.warn(
2889 `Note: --boot is a Windows-only option and has no effect on ${process.platform}; installing the standard login-based service.`,
2890 );
2891 }
2892
2893 if (!backend.automated) {
2894 // Unsupported platforms surface their manual steps via the install error.
2895 yield* backend.install({
2896 executablePath: process.execPath,
2897 port,
2898 version: CLI_VERSION,
2899 boot,
2900 });
2901 return;
2902 }
2903
2904 const status = yield* backend.status();
2905 const active = yield* readActiveLocalServerManifest().pipe(Effect.orElseSucceed(() => null));
2906 const plan = planServiceInstall({
2907 registered: status.registered,
2908 running: status.running,
2909 activeKind: active?.kind ?? null,
2910 activePid: active?.pid ?? null,
2911 servicePid: status.pid,
2912 activeVersion: active?.owner.version ?? null,
2913 activeExecutablePath: active?.owner.executablePath ?? null,
2914 activePort: active ? portFromOrigin(active.connection.origin) : null,
2915 requestedPort: port,
2916 currentVersion: CLI_VERSION,
2917 currentExecutablePath: process.execPath,
2918 });
2919
2920 if (plan === "noop") {
2921 const where = active ? ` at ${active.connection.origin} (pid ${active.pid})` : "";
2922 console.log(`Executor background service is already running${where}.`);
2923 console.log(`Open it in your browser, already signed in, with: ${cliPrefix} web`);
2924 return;
2925 }

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