service live configslop

This commit is contained in:
legop3
2026-09-14 17:56:53 -04:00
parent 881583ee0a
commit 91e0cc3886
69 changed files with 1188 additions and 619 deletions
+25 -6
View File
@@ -1,21 +1,40 @@
// MediaMTX Service
// Purpose: Composes server configuration, runtime paths, and child-process supervision.
// Scope: Starts MediaMTX only after the HTTP auth endpoint is listening and stops it with the server.
const { loadConfig } = require('../../configuration');
const { loadConfig, registerConfigurationHandler } = require('../../configuration');
const globalConfig = require('../../globals/config');
const logger = require('../../globals/logger').child('mediamtx');
const { createMediaMtxSupervisor } = require('./supervisor');
const supervisor = createMediaMtxSupervisor({
config: loadConfig(),
serverPort: globalConfig.port,
logger,
});
let supervisor = createSupervisor();
let started = false;
function createSupervisor() {
return createMediaMtxSupervisor({
config: loadConfig(),
serverPort: globalConfig.port,
logger,
});
}
function startMediaMtx() {
started = true;
return supervisor.start();
}
function stopSupervisor() {
return new Promise((resolve) => supervisor.stop(resolve));
}
registerConfigurationHandler('media', async () => {
// MediaMTX consumes a generated document rather than the Node configuration
// object directly. Replace its child process so every media setting is
// regenerated and applied as one coherent revision.
await stopSupervisor();
supervisor = createSupervisor();
if (started) supervisor.start();
});
/*
Other services already use process signal hooks for their own workers. This hook performs
only synchronous signal delivery; systemd's default control-group cleanup remains the final
@@ -39,6 +39,9 @@ function createMediaMtxSupervisor(deps) {
function start() {
if (child) return child;
// `stop()` marks the old lifecycle as intentional. Reset that marker when
// the same supervisor is started again so later crashes remain fatal.
stopping = false;
const generatedConfig = buildMediaMtxConfig({ config, serverPort, snapshotWriterPath });
/*