mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-27 00:17:29 +00:00
fix: honor gateway command env in status reads
This commit is contained in:
@@ -190,6 +190,37 @@ describe("gatherDaemonStatus", () => {
|
||||
expect(status.rpc?.url).toBe("wss://override.example:18790");
|
||||
});
|
||||
|
||||
it("reuses command environment when reading runtime status", async () => {
|
||||
serviceReadCommand.mockResolvedValueOnce({
|
||||
programArguments: ["/bin/node", "cli", "gateway", "--port", "19001"],
|
||||
environment: {
|
||||
OPENCLAW_GATEWAY_PORT: "19001",
|
||||
OPENCLAW_CONFIG_PATH: "/tmp/openclaw-daemon/openclaw.json",
|
||||
OPENCLAW_STATE_DIR: "/tmp/openclaw-daemon",
|
||||
} as Record<string, string>,
|
||||
});
|
||||
serviceReadRuntime.mockImplementationOnce(async (env?: NodeJS.ProcessEnv) => ({
|
||||
status: env?.OPENCLAW_GATEWAY_PORT === "19001" ? "running" : "unknown",
|
||||
detail: env?.OPENCLAW_GATEWAY_PORT ?? "missing-port",
|
||||
}));
|
||||
|
||||
const status = await gatherDaemonStatus({
|
||||
rpc: {},
|
||||
probe: false,
|
||||
deep: false,
|
||||
});
|
||||
|
||||
expect(serviceReadRuntime).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
OPENCLAW_GATEWAY_PORT: "19001",
|
||||
}),
|
||||
);
|
||||
expect(status.service.runtime).toMatchObject({
|
||||
status: "running",
|
||||
detail: "19001",
|
||||
});
|
||||
});
|
||||
|
||||
it("resolves daemon gateway auth password SecretRef values before probing", async () => {
|
||||
daemonLoadedConfig = {
|
||||
gateway: {
|
||||
|
||||
@@ -258,17 +258,21 @@ export async function gatherDaemonStatus(
|
||||
} & FindExtraGatewayServicesOptions,
|
||||
): Promise<DaemonStatus> {
|
||||
const service = resolveGatewayService();
|
||||
const [loaded, command, runtime] = await Promise.all([
|
||||
service.isLoaded({ env: process.env }).catch(() => false),
|
||||
service.readCommand(process.env).catch(() => null),
|
||||
service.readRuntime(process.env).catch((err) => ({ status: "unknown", detail: String(err) })),
|
||||
const command = await service.readCommand(process.env).catch(() => null);
|
||||
const serviceEnv = command?.environment
|
||||
? ({
|
||||
...process.env,
|
||||
...command.environment,
|
||||
} satisfies NodeJS.ProcessEnv)
|
||||
: process.env;
|
||||
const [loaded, runtime] = await Promise.all([
|
||||
service.isLoaded({ env: serviceEnv }).catch(() => false),
|
||||
service.readRuntime(serviceEnv).catch((err) => ({ status: "unknown", detail: String(err) })),
|
||||
]);
|
||||
const configAudit = await auditGatewayServiceConfig({
|
||||
env: process.env,
|
||||
command,
|
||||
});
|
||||
|
||||
const serviceEnv = command?.environment ?? undefined;
|
||||
const {
|
||||
mergedDaemonEnv,
|
||||
cliCfg,
|
||||
@@ -276,7 +280,7 @@ export async function gatherDaemonStatus(
|
||||
cliConfigSummary,
|
||||
daemonConfigSummary,
|
||||
configMismatch,
|
||||
} = await loadDaemonConfigContext(serviceEnv);
|
||||
} = await loadDaemonConfigContext(command?.environment);
|
||||
const { gateway, daemonPort, cliPort, probeUrlOverride } = await resolveGatewayStatusSummary({
|
||||
cliCfg,
|
||||
daemonCfg,
|
||||
|
||||
Reference in New Issue
Block a user