fix: propagate config env vars to gateway services (#1735) (thanks @Seredeep)
This commit is contained in:
@@ -7,6 +7,8 @@ import {
|
||||
} from "../daemon/runtime-paths.js";
|
||||
import { buildServiceEnvironment } from "../daemon/service-env.js";
|
||||
import { formatCliCommand } from "../cli/command-format.js";
|
||||
import { collectConfigEnvVars } from "../config/env-vars.js";
|
||||
import type { ClawdbotConfig } from "../config/types.js";
|
||||
import type { GatewayDaemonRuntime } from "./daemon-runtime.js";
|
||||
|
||||
type WarnFn = (message: string, title?: string) => void;
|
||||
@@ -31,8 +33,8 @@ export async function buildGatewayInstallPlan(params: {
|
||||
devMode?: boolean;
|
||||
nodePath?: string;
|
||||
warn?: WarnFn;
|
||||
/** Environment variables from config.env.vars to include in the service environment */
|
||||
configEnvVars?: Record<string, string | undefined>;
|
||||
/** Full config to extract env vars from (env vars + inline env keys). */
|
||||
config?: ClawdbotConfig;
|
||||
}): Promise<GatewayInstallPlan> {
|
||||
const devMode = params.devMode ?? resolveGatewayDevMode();
|
||||
const nodePath =
|
||||
@@ -62,14 +64,11 @@ export async function buildGatewayInstallPlan(params: {
|
||||
: undefined,
|
||||
});
|
||||
|
||||
// Merge config.env.vars into the service environment.
|
||||
// Merge config env vars into the service environment (vars + inline env keys).
|
||||
// Config env vars are added first so service-specific vars take precedence.
|
||||
const environment: Record<string, string | undefined> = {};
|
||||
if (params.configEnvVars) {
|
||||
for (const [key, value] of Object.entries(params.configEnvVars)) {
|
||||
if (value) environment[key] = value;
|
||||
}
|
||||
}
|
||||
const environment: Record<string, string | undefined> = {
|
||||
...collectConfigEnvVars(params.config),
|
||||
};
|
||||
Object.assign(environment, serviceEnvironment);
|
||||
|
||||
return { programArguments, workingDirectory, environment };
|
||||
|
||||
Reference in New Issue
Block a user