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

Function serviceEnvironment

apps/cli/src/service.ts:170–207  ·  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 ] as const;
181 const passThrough = Object.fromEntries(
182 passThroughKeys.flatMap((key) => {
183 const value = process.env[key];
184 return value ? [[key, value] as const] : [];
185 }),
186 );
187
188 return {
189 // Marks the process as OS-supervised so the daemon resolves its bearer token
190 // from the durable 0600 auth.json (the secret is never in the unit itself).
191 EXECUTOR_SUPERVISED: "1",
192 // Pin the data/scope dirs explicitly: launchd/systemd give a minimal
193 // environment and we never want the daemon to fall back to a different home
194 // or cwd than the user's singleton local service.
195 EXECUTOR_DATA_DIR: dataDir,
196 EXECUTOR_SCOPE_DIR: process.env.EXECUTOR_SCOPE_DIR ?? dataDir,
197 // Stamp the installing version so `service status` can flag drift after an
198 // upgrade where the unit still points at an older binary path.
199 EXECUTOR_SERVICE_VERSION: descriptor.version,
200 // A launchd/systemd unit starts with a bare PATH — without the user's PATH
201 // the daemon can't find pyenv/nvm/volta/Homebrew tools that integrations may
202 // shell out to. `service install` runs from the user's shell, so its own
203 // PATH is the right one to bake in. (Reference: opencode shell-env capture.)
204 ...(process.env.PATH ? { PATH: process.env.PATH } : {}),
205 ...passThrough,
206 };
207};
208
209// ---------------------------------------------------------------------------
210// macOS — launchd LaunchAgent (fully built)

Callers 3

makeLaunchdBackendFunction · 0.85
makeSystemdBackendFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected