// Shared database connection for the music scripts: MUSIC_DB_URL (e.g. the optional // music_collector role) or DB_URL (the app role, as in the image's prod.env). import postgres from 'postgres'; export function musicDb() { const url = process.env.MUSIC_DB_URL || process.env.DB_URL; if (!url) throw new Error('Set MUSIC_DB_URL or DB_URL'); return postgres(url, { max: 1, prepare: false, connect_timeout: 10, onnotice: () => {} }); } export const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms)); export function arg(name: string): string | undefined { const i = process.argv.indexOf(`--${name}`); return i >= 0 ? process.argv[i + 1] : undefined; }