Fix live stream buffering and add websocket status

This commit is contained in:
Hermes Agent
2026-05-21 00:48:55 +02:00
parent fda46887ed
commit 17bf8d4e3a
6 changed files with 262 additions and 13 deletions

View File

@@ -9,6 +9,7 @@ const { EffectsService } = require('./effects');
const { HomeAssistantClient } = require('./homeassistant');
const { StreamMixer } = require('./streamMixer');
const { createApiRouter } = require('./routes');
const { attachStatusWebSocket } = require('./wsHub');
function buildApp(config) {
const filestash = new FilestashClient({
@@ -93,7 +94,7 @@ function buildApp(config) {
function main() {
const config = loadConfig();
const { app, effects } = buildApp(config);
const { app, effects, mixer } = buildApp(config);
const server = app.listen(config.env.port, () => {
// eslint-disable-next-line no-console
@@ -108,6 +109,12 @@ function main() {
}
});
const wsHub = attachStatusWebSocket({
server,
mixer,
entity: config.homeAssistant.allowedMediaPlayer,
});
// Warm the cache in the background; ignore failures, they will surface on /api/effects.
effects.list().catch((err) => {
// eslint-disable-next-line no-console
@@ -118,6 +125,7 @@ function main() {
process.on(sig, () => {
// eslint-disable-next-line no-console
console.log(`Received ${sig}, shutting down.`);
wsHub.close();
server.close(() => process.exit(0));
setTimeout(() => process.exit(1), 5000).unref();
});