fix: cap postgres connection pools

This commit is contained in:
Codex
2026-05-15 00:18:42 +00:00
parent c930607316
commit c206f13216
10 changed files with 47 additions and 8 deletions
@@ -13,6 +13,7 @@ interface RuntimeConfig {
port: number;
databaseUrl: string;
logFile: string;
databasePoolMax: number;
}
interface ProjectRow {
@@ -90,11 +91,17 @@ function configFromEnv(): RuntimeConfig {
port: Number(process.env.PORT || 4233),
databaseUrl,
logFile: process.env.LOG_FILE || "",
databasePoolMax: Math.max(1, Math.min(8, Number(process.env.DATABASE_POOL_MAX || 1) || 1)),
};
}
const config = configFromEnv();
const sql = postgres(config.databaseUrl, { max: 8, idle_timeout: 20, connect_timeout: 10 });
const sql = postgres(config.databaseUrl, {
max: config.databasePoolMax,
idle_timeout: 20,
connect_timeout: 10,
connection: { application_name: "unidesk-project-manager" },
});
const logWriter = config.logFile
? createHourlyJsonlWriter({
baseLogFile: config.logFile,