Merge pull request #632 from ssahai/bugfix/catch_error
Handle process kills gracefully
This commit is contained in:
commit
a7fa1b47fe
|
@ -204,7 +204,16 @@ class Job {
|
|||
(timeout >= 0 &&
|
||||
set_timeout(async _ => {
|
||||
this.logger.info(`Timeout exceeded timeout=${timeout}`);
|
||||
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)) ||
|
||||
null;
|
||||
this.#active_timeouts.push(kill_timeout);
|
||||
|
@ -214,7 +223,16 @@ class Job {
|
|||
event_bus.emit('stderr', data);
|
||||
} else if (stderr.length > this.runtime.output_max_size) {
|
||||
this.logger.info(`stderr length exceeded`);
|
||||
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 {
|
||||
stderr += data;
|
||||
output += data;
|
||||
|
@ -226,7 +244,16 @@ class Job {
|
|||
event_bus.emit('stdout', data);
|
||||
} else if (stdout.length > this.runtime.output_max_size) {
|
||||
this.logger.info(`stdout length exceeded`);
|
||||
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 {
|
||||
stdout += data;
|
||||
output += data;
|
||||
|
@ -271,8 +298,8 @@ class Job {
|
|||
const { emit_event_bus_result, emit_event_bus_stage } =
|
||||
event_bus === null
|
||||
? {
|
||||
emit_event_bus_result: () => {},
|
||||
emit_event_bus_stage: () => {},
|
||||
emit_event_bus_result: () => { },
|
||||
emit_event_bus_stage: () => { },
|
||||
}
|
||||
: {
|
||||
emit_event_bus_result: (stage, result, event_bus) => {
|
||||
|
@ -397,7 +424,7 @@ class Job {
|
|||
// Then clear them out of the process tree
|
||||
try {
|
||||
process.kill(proc, 'SIGKILL');
|
||||
} catch {
|
||||
} catch (e) {
|
||||
// Could already be dead and just needs to be waited on
|
||||
this.logger.debug(
|
||||
`Got error while SIGKILLing process ${proc}:`,
|
||||
|
|
Loading…
Reference in New Issue