mirror of
https://github.com/tale/headplane.git
synced 2026-08-11 22:36:53 +00:00
fix: env variables did not resolve in prod
This commit is contained in:
+26
-15
@@ -38,27 +38,38 @@ export function configureLogger(env: string | undefined) {
|
||||
log.debug('config', 'It is recommended this be disabled in production');
|
||||
}
|
||||
|
||||
interface Overrides {
|
||||
loadEnv: string | undefined;
|
||||
path: string | undefined;
|
||||
export interface EnvOverrides {
|
||||
loadEnv: boolean;
|
||||
path: string;
|
||||
}
|
||||
|
||||
export type EnvOverrides = typeof schema.infer;
|
||||
const schema = type({
|
||||
loadEnv: booleanEnv.default('false'),
|
||||
path: 'string = "/etc/headplane/config.yaml"',
|
||||
});
|
||||
|
||||
export function configureConfig(overrides: Overrides) {
|
||||
const result = schema(overrides);
|
||||
if (result instanceof type.errors) {
|
||||
export function configureConfig(
|
||||
overrides: Partial<EnvOverrides>,
|
||||
): EnvOverrides {
|
||||
const loadResult = booleanEnv(overrides.loadEnv);
|
||||
if (loadResult instanceof type.errors) {
|
||||
log.error(
|
||||
'config',
|
||||
'HEADPLANE_LOAD_ENV_OVERRIDES or HEADPLANE_CONFIG_PATH value is invalid: %s',
|
||||
result.summary,
|
||||
'HEADPLANE_LOAD_ENV_OVERRIDES value is invalid: %s',
|
||||
loadResult.summary,
|
||||
);
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return result;
|
||||
const pathResult = type('string | undefined')(overrides.path);
|
||||
if (pathResult instanceof type.errors) {
|
||||
log.error(
|
||||
'config',
|
||||
'HEADPLANE_CONFIG_PATH value is invalid: %s',
|
||||
pathResult.summary,
|
||||
);
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return {
|
||||
loadEnv: loadResult,
|
||||
path: pathResult ?? '/etc/headplane/config.yaml',
|
||||
};
|
||||
}
|
||||
|
||||
+4
-4
@@ -1,4 +1,4 @@
|
||||
import { versions } from 'node:process';
|
||||
import { env, versions } from 'node:process';
|
||||
import type { UpgradeWebSocket } from 'hono/ws';
|
||||
import { createHonoServer } from 'react-router-hono-server/node';
|
||||
import type { WebSocket } from 'ws';
|
||||
@@ -20,11 +20,11 @@ declare global {
|
||||
// This module contains a side-effect because everything running here
|
||||
// exists for the lifetime of the process, making it appropriate.
|
||||
log.info('server', 'Running Node.js %s', versions.node);
|
||||
configureLogger(process.env[envVariables.debugLog]);
|
||||
configureLogger(env[envVariables.debugLog]);
|
||||
const config = await loadConfig(
|
||||
configureConfig({
|
||||
loadEnv: process.env[envVariables.envOverrides],
|
||||
path: process.env[envVariables.configPath],
|
||||
loadEnv: env[envVariables.envOverrides],
|
||||
path: env[envVariables.configPath],
|
||||
}),
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user