From bc3c6a77069d4a255faaf3530dc7e0092cff4224 Mon Sep 17 00:00:00 2001 From: ggolda <38298010+ggolda@users.noreply.github.com> Date: Tue, 17 Dec 2024 17:21:31 -0700 Subject: [PATCH] graceful shutdown protocol implemented for ai highlighter (#5268) --- .../highlighter/ai-highlighter/ai-highlighter.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/services/highlighter/ai-highlighter/ai-highlighter.ts b/app/services/highlighter/ai-highlighter/ai-highlighter.ts index 467fb919c3ff..58f58c129a68 100644 --- a/app/services/highlighter/ai-highlighter/ai-highlighter.ts +++ b/app/services/highlighter/ai-highlighter/ai-highlighter.ts @@ -4,6 +4,7 @@ import { AiHighlighterUpdater } from './updater'; import { duration } from 'moment'; import { ICoordinates } from '..'; import kill from 'tree-kill'; +import { getOS, OS } from 'util/operating-systems'; export enum EHighlighterInputTypes { KILL = 'kill', @@ -130,7 +131,13 @@ export function getHighlightClips( cancelSignal.addEventListener('abort', () => { console.log('ending highlighter process'); messageBuffer.clear(); - kill(childProcess.pid!, 'SIGINT'); + + // windows doesn't support signals and we have to use the custom graceful shutdown + if (getOS() === OS.Windows) { + childProcess.stdin?.write('quit\n'); + } else { + kill(childProcess.pid!, 'SIGINT'); + } reject(new Error('Highlight generation canceled')); }); }