fix: allow specifying otel config in --env-file (#29240)

Alternative to https://github.com/denoland/deno/pull/28127 that does cli
flag parsing, then env file loading, then resolves config with env vars.

This also fixes several other issues related to env vars in the
--env-file not being used for certain config.

Closes https://github.com/denoland/deno/issues/27851
Closes https://github.com/denoland/deno/issues/29171
Closes https://github.com/denoland/deno/pull/28127
Closes #29256
This commit is contained in:
David Sherret 2025-05-11 20:09:52 -05:00 committed by GitHub
parent 853982238a
commit e601df6bfb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 203 additions and 147 deletions

View file

@ -805,7 +805,7 @@ function bootstrapMainRuntime(runtimeOptions, warmup = false) {
9: servePort,
10: serveHost,
11: serveIsMain,
12: serveWorkerCount,
12: serveWorkerCountOrIndex,
13: otelConfig,
15: standalone,
} = runtimeOptions;
@ -813,13 +813,12 @@ function bootstrapMainRuntime(runtimeOptions, warmup = false) {
denoNs.build.standalone = standalone;
if (mode === executionModes.serve) {
if (serveIsMain && serveWorkerCount) {
// deno-lint-ignore no-global-assign
console = new internalConsole.Console((msg, level) =>
core.print("[serve-worker-0 ] " + msg, level > 1)
);
} else if (serveWorkerCount !== null) {
const base = `serve-worker-${serveWorkerCount + 1}`;
const hasMultipleThreads = serveIsMain
? serveWorkerCountOrIndex > 0 // count > 0
: true;
if (hasMultipleThreads) {
const serveLogIndex = serveIsMain ? 0 : (serveWorkerCountOrIndex + 1);
const base = `serve-worker-${serveLogIndex}`;
// 15 = "serve-worker-nn".length, assuming
// serveWorkerCount < 100
const prefix = `[${StringPrototypePadEnd(base, 15, " ")}]`;
@ -870,7 +869,13 @@ function bootstrapMainRuntime(runtimeOptions, warmup = false) {
);
}
if (mode === executionModes.serve) {
serve({ servePort, serveHost, serveIsMain, serveWorkerCount });
serve({
servePort,
serveHost,
workerCountWhenMain: serveIsMain
? serveWorkerCountOrIndex
: undefined,
});
}
}
});