Add player functionality with HLS support and API integration
- Implemented a new Player class in player.js to handle audio playback, including HLS support using hls.js. - Created a shared API module in api.js for making HTTP requests with proper error handling. - Added DOM utility functions in dom.js for creating and clearing elements. - Introduced WebSocket connection handling in ws.js for real-time updates. - Developed a comprehensive CSS stylesheet for styling the application, including a high-contrast theme.
This commit is contained in:
25
server/streams/checker.js
Normal file
25
server/streams/checker.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import cron from 'node-cron';
|
||||
import { getDb } from '../db/index.js';
|
||||
import { probeStream } from './probe.js';
|
||||
|
||||
const probe = probeStream;
|
||||
|
||||
export async function runHealthCheck() {
|
||||
const db = getDb();
|
||||
const streams = db.prepare('SELECT id, url FROM streams').all();
|
||||
const update = db.prepare(
|
||||
"UPDATE streams SET last_status = ?, last_checked_at = datetime('now') WHERE id = ?"
|
||||
);
|
||||
for (const s of streams) {
|
||||
const status = await probe(s.url);
|
||||
update.run(status, s.id);
|
||||
}
|
||||
return streams.length;
|
||||
}
|
||||
|
||||
export function scheduleHealthCheck(expr) {
|
||||
if (!expr) return null;
|
||||
return cron.schedule(expr, () => {
|
||||
runHealthCheck().catch((err) => console.error('[health]', err));
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user