mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-09 07:29:04 -07:00
Clean up listener after cli run
This commit is contained in:
parent
8ca3dde779
commit
5f5d3c1b04
1 changed files with 8 additions and 4 deletions
|
|
@ -278,20 +278,22 @@ class CLI {
|
|||
// eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/explicit-module-boundary-types
|
||||
let thread: any;
|
||||
|
||||
process.on('exit', () => {
|
||||
const exitHandler = () => {
|
||||
if (thread) {
|
||||
try {
|
||||
// eslint-disable-next-line no-console
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('Main thread exiting, cleaning up running CLI');
|
||||
this.killThread(thread);
|
||||
} catch (err) {
|
||||
// eslint-disable-next-line no-console
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('Error running cliUtils on Exit function');
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(err);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
process.on('exit', exitHandler);
|
||||
|
||||
const cliExitCode: number = await new Promise((resolve) => {
|
||||
try {
|
||||
|
|
@ -334,6 +336,8 @@ class CLI {
|
|||
}
|
||||
});
|
||||
|
||||
process.removeListener('exit', exitHandler);
|
||||
|
||||
thread = undefined;
|
||||
|
||||
if (!this.config.logFullCliOutput) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue