Files
mtusi2026lab6/scripts/wait-grafana.ts
T

6 lines
598 B
TypeScript

// Empty SQLite on the owned HDD completed641 migrations during the old120s
// deadline without an error. Allow bounded cold initialization, not only warm restart.
const deadline=Date.now()+600000;
while(Date.now()<deadline){try{const response=await fetch('http://127.0.0.1:28306/api/health',{signal:AbortSignal.timeout(2000)}),body=await response.json();if(response.status===200&&body.database==='ok'&&body.version==='13.3.1'){console.log('Grafana13.3.1 database and HTTP server ready');process.exit(0)}}catch{}await Bun.sleep(500);}
throw new Error('Grafana native readiness deadline exceeded');