Skip to content

Commit

Permalink
Merge pull request #14 from chooper/charles/fix-thread-leaks
Browse files Browse the repository at this point in the history
Fix thread leaks (fixes #13)
  • Loading branch information
kdolan authored Oct 12, 2022
2 parents 729ecb3 + 7e7662e commit 263e21a
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions service/RecordingThread.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ class RecordingThread{

__initThread(){
if(this.__useAltRecording) {
log.silly('Initializing Alternative Recording Thread (Fork)')
log.debug('Using a new process for recording');
this.__startedForkedThread();
}
else{ //Use Alt
log.debug('Using a new thread for recording');
this.__startWorkerThread();
}
}
Expand All @@ -33,8 +34,7 @@ class RecordingThread{
this._recordingWorker.on("message", incoming => log.debug(`Message from Recording Worker ${this.threadId}: ${incoming}`));
this._recordingWorker.on("error", code => new Error(`Recording Worker ${this.threadId} error with exit code ${code}`));
this._recordingWorker.on("exit", code => {
log.debug(`Worker ${this.threadId} stopped with exit code ${code}. Restarting`);
this.__initThread();
log.debug(`Worker thread ${this.threadId} stopped with exit code ${code}.`);
}
);
}
Expand All @@ -45,8 +45,7 @@ class RecordingThread{
this._child.stdout.on("data", data => console.log(data.toString().replace(/(\r\n|\n|\r)/gm, "")));
this._child.on("error", code => new Error(`Recording Worker ${this.threadId} error with exit code ${code}`));
this._child.on("exit", code => {
log.debug(`Worker ${this.threadId} stopped with exit code ${code}. Restarting`);
this.__initThread();
log.debug(`Worker process ${this.threadId} stopped with exit code ${code}.`);
}
);
}
Expand Down

0 comments on commit 263e21a

Please sign in to comment.