Skip to content

Commit

Permalink
graceful shutdown protocol implemented for ai highlighter (#5268)
Browse files Browse the repository at this point in the history
  • Loading branch information
ggolda authored Dec 18, 2024
1 parent efc54a8 commit bc3c6a7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app/services/highlighter/ai-highlighter/ai-highlighter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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'));
});
}
Expand Down

0 comments on commit bc3c6a7

Please sign in to comment.