fix: cap postgres connection pools
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user