server restart stuck fixes

This commit is contained in:
legop3
2026-06-10 13:16:57 -04:00
parent 5770dc8849
commit 8d90a29345
5 changed files with 64 additions and 13 deletions
@@ -95,6 +95,7 @@ const workerEngine = createAudioForwardWorkerEngine({
const {
ensureWorker,
stopWorker,
stopAllWorkers,
playUploadedAudio,
playServerAudioFile,
stopPlayback,
@@ -104,6 +105,21 @@ const {
startSilenceWriter,
} = workerEngine;
function installShutdownHooks() {
const shutdown = (signal) => {
// Audio forwarding owns long-lived ffmpeg publisher/writer pairs. Stop them
// synchronously on process signals so a systemd restart does not have to
// wait for orphaned media workers to notice that their parent is gone.
stopAllWorkers(signal || 'process-exit');
};
process.once('exit', () => shutdown('exit'));
process.once('SIGINT', () => shutdown('SIGINT'));
process.once('SIGTERM', () => shutdown('SIGTERM'));
}
installShutdownHooks();
registerAudioForwardHooks({
io,
roverManager,