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

Function serviceEnvironment

apps/cli/src/service.ts:170–211  ·  view source on GitHub ↗
(
  descriptor: ServiceDescriptor,
  dataDir: string,
)

Source from the content-addressed store, hash-verified

168];
169
170const serviceEnvironment = (
171 descriptor: ServiceDescriptor,
172 dataDir: string,
173): Record<string, string> => {
174 const passThroughKeys = [
175 "EXECUTOR_CLIENT",
176 "EXECUTOR_SENTRY_DSN",
177 "EXECUTOR_SENTRY_RELEASE",
178 "EXECUTOR_SENTRY_ENVIRONMENT",
179 "EXECUTOR_RUN_ID",
180 // Analytics opt-out must survive into the supervised unit's minimal env,
181 // or an opted-out install would silently re-enable analytics under launchd.
182 "DO_NOT_TRACK",
183 "EXECUTOR_DISABLE_ANALYTICS",
184 ] as const;
185 const passThrough = Object.fromEntries(
186 passThroughKeys.flatMap((key) => {
187 const value = process.env[key];
188 return value ? [[key, value] as const] : [];
189 }),
190 );
191
192 return {
193 // Marks the process as OS-supervised so the daemon resolves its bearer token
194 // from the durable 0600 auth.json (the secret is never in the unit itself).
195 EXECUTOR_SUPERVISED: "1",
196 // Pin the data/scope dirs explicitly: launchd/systemd give a minimal
197 // environment and we never want the daemon to fall back to a different home
198 // or cwd than the user's singleton local service.
199 EXECUTOR_DATA_DIR: dataDir,
200 EXECUTOR_SCOPE_DIR: process.env.EXECUTOR_SCOPE_DIR ?? dataDir,
201 // Stamp the installing version so `service status` can flag drift after an
202 // upgrade where the unit still points at an older binary path.
203 EXECUTOR_SERVICE_VERSION: descriptor.version,
204 // A launchd/systemd unit starts with a bare PATH — without the user's PATH
205 // the daemon can't find pyenv/nvm/volta/Homebrew tools that integrations may
206 // shell out to. `service install` runs from the user's shell, so its own
207 // PATH is the right one to bake in. (Reference: opencode shell-env capture.)
208 ...(process.env.PATH ? { PATH: process.env.PATH } : {}),
209 ...passThrough,
210 };
211};
212
213// ---------------------------------------------------------------------------
214// macOS — launchd LaunchAgent (fully built)

Callers 3

makeLaunchdBackendFunction · 0.85
makeSystemdBackendFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected