Log de diagnostic : hôte PostgreSQL ciblé au démarrage
Affiche host/port/db/user à la connexion et un message explicite en cas d'échec d'authentification persistant, pour identifier immédiatement une stack déployée avec une ancienne version du compose. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Fkg15RCxNgUys4ru73He2o
This commit is contained in:
1 file changed
+14
-1
+14
-1
@@ -11,12 +11,25 @@ export const pool = new pg.Pool({
|
||||
export const query = (text, params) => pool.query(text, params);
|
||||
|
||||
export async function waitForDb(retries = 30, delayMs = 1000) {
|
||||
console.log(
|
||||
`Connecting to PostgreSQL: host=${config.db.host} port=${config.db.port} ` +
|
||||
`db=${config.db.database} user=${config.db.user}`
|
||||
);
|
||||
for (let i = 1; i <= retries; i++) {
|
||||
try {
|
||||
await pool.query('SELECT 1');
|
||||
return;
|
||||
} catch (err) {
|
||||
if (i === retries) throw err;
|
||||
if (i === retries) {
|
||||
if (err.code === '28P01') {
|
||||
console.error(
|
||||
'Authentication failed: the sbc_app password in PostgreSQL does not match ' +
|
||||
'PGPASSWORD/APP_DB_PASSWORD. The db-sync service realigns it at every stack ' +
|
||||
'start — make sure it ran against this same database.'
|
||||
);
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
await new Promise((r) => setTimeout(r, delayMs));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user