mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-11-15 03:02:17 -05:00
service live configslop
This commit is contained in:
@@ -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 });
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user