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
@@ -8,7 +8,7 @@ module.exports = {
feature: true,
defaultValue: { enabled: false, captureCooldownMs: 10000 },
schema: strictObject({
enabled: boolean({ description: 'Starts the Kinect worker and exposes authorized frame capture after restart.' }),
enabled: boolean({ description: 'Immediately starts the Kinect worker and exposes authorized frame capture.' }),
captureCooldownMs: integer({ description: 'Minimum milliseconds between accepted Kinect frame-capture requests across all clients.', minimum: 0, maximum: 3600000 }),
}, {
title: 'Kinect',
+5 -1
View File
@@ -1,7 +1,7 @@
// Kinect Service
// Purpose: Composes Kinect hardware capture and browser socket delivery.
// Scope: Exposes session-readable state while keeping startup side effects in this service folder.
const { loadConfig } = require('../../configuration');
const { loadConfig, registerConfigurationHandler } = require('../../configuration');
const hardware = require('./hardware');
const { registerKinectSocketGateway, kinectEvents } = require('./socketGateway');
@@ -11,6 +11,10 @@ const gateway = registerKinectSocketGateway({
hardware,
});
registerConfigurationHandler('kinect', (kinectConfig) => {
gateway.reconfigure({ kinect: kinectConfig || {} });
});
module.exports = {
getState: gateway.getState,
kinectEvents,
@@ -33,7 +33,7 @@ function normalizeKinectConfig(config = {}) {
}
function registerKinectSocketGateway({ config, hardware }) {
const settings = normalizeKinectConfig(config);
let settings = normalizeKinectConfig(config);
let captureCooldownUntil = 0;
let busy = false;
let lastAction = null;
@@ -206,8 +206,31 @@ function registerKinectSocketGateway({ config, hardware }) {
}
}
function reconfigure(nextConfig) {
const previousEnabled = settings.enabled;
settings = normalizeKinectConfig(nextConfig);
lastError = null;
// The native worker is the Kinect service's complete hardware runtime.
// Restarting only when the enabled state changes avoids interrupting an
// unrelated cooldown edit while still making enable/disable immediate.
if (previousEnabled && !settings.enabled) {
hardware.stopWorker();
busy = false;
} else if (!previousEnabled && settings.enabled) {
try {
hardware.startWorker();
} catch (err) {
lastError = err.message || 'kinect worker failed to start';
logger.warn('Kinect worker startup failed after configuration change', { err: lastError });
}
}
emitStatusChange();
}
return {
getState: buildStatus,
reconfigure,
};
}