Fix live stream buffering and add websocket status
This commit is contained in:
@@ -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();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user