Try-Catch process kills to handle dead processes
This commit is contained in:
parent
dc4bb294b6
commit
d8af1ee301
|
@ -204,7 +204,16 @@ class Job {
|
||||||
(timeout >= 0 &&
|
(timeout >= 0 &&
|
||||||
set_timeout(async _ => {
|
set_timeout(async _ => {
|
||||||
this.logger.info(`Timeout exceeded timeout=${timeout}`);
|
this.logger.info(`Timeout exceeded timeout=${timeout}`);
|
||||||
process.kill(proc.pid, 'SIGKILL');
|
try {
|
||||||
|
process.kill(proc.pid, 'SIGKILL');
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
// Could already be dead and just needs to be waited on
|
||||||
|
this.logger.debug(
|
||||||
|
`Got error while SIGKILLing process ${proc}:`,
|
||||||
|
e
|
||||||
|
);
|
||||||
|
}
|
||||||
}, timeout)) ||
|
}, timeout)) ||
|
||||||
null;
|
null;
|
||||||
this.#active_timeouts.push(kill_timeout);
|
this.#active_timeouts.push(kill_timeout);
|
||||||
|
@ -214,7 +223,16 @@ class Job {
|
||||||
event_bus.emit('stderr', data);
|
event_bus.emit('stderr', data);
|
||||||
} else if (stderr.length > this.runtime.output_max_size) {
|
} else if (stderr.length > this.runtime.output_max_size) {
|
||||||
this.logger.info(`stderr length exceeded`);
|
this.logger.info(`stderr length exceeded`);
|
||||||
process.kill(proc.pid, 'SIGKILL');
|
try {
|
||||||
|
process.kill(proc.pid, 'SIGKILL');
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
// Could already be dead and just needs to be waited on
|
||||||
|
this.logger.debug(
|
||||||
|
`Got error while SIGKILLing process ${proc}:`,
|
||||||
|
e
|
||||||
|
);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
stderr += data;
|
stderr += data;
|
||||||
output += data;
|
output += data;
|
||||||
|
@ -226,7 +244,16 @@ class Job {
|
||||||
event_bus.emit('stdout', data);
|
event_bus.emit('stdout', data);
|
||||||
} else if (stdout.length > this.runtime.output_max_size) {
|
} else if (stdout.length > this.runtime.output_max_size) {
|
||||||
this.logger.info(`stdout length exceeded`);
|
this.logger.info(`stdout length exceeded`);
|
||||||
process.kill(proc.pid, 'SIGKILL');
|
try {
|
||||||
|
process.kill(proc.pid, 'SIGKILL');
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
// Could already be dead and just needs to be waited on
|
||||||
|
this.logger.debug(
|
||||||
|
`Got error while SIGKILLing process ${proc}:`,
|
||||||
|
e
|
||||||
|
);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
stdout += data;
|
stdout += data;
|
||||||
output += data;
|
output += data;
|
||||||
|
|
Loading…
Reference in New Issue