logs: use stream.destroy() instead of custom hooks
This commit is contained in:
@@ -89,7 +89,11 @@ function sudo(tag, args, options, callback) {
|
||||
e.code = code;
|
||||
e.signal = signal;
|
||||
|
||||
debug(`${tag}: ${SUDO} ${spawnArgs.join(' ').replace(/\n/g, '\\n')} errored`, e);
|
||||
if (cp.terminated) {
|
||||
debug(`${tag}: ${SUDO} ${spawnArgs.join(' ').replace(/\n/g, '\\n')} terminated`); // was killed by us
|
||||
} else {
|
||||
debug(`${tag}: ${SUDO} ${spawnArgs.join(' ').replace(/\n/g, '\\n')} errored`, e);
|
||||
}
|
||||
|
||||
callback(e);
|
||||
});
|
||||
@@ -107,6 +111,7 @@ function sudo(tag, args, options, callback) {
|
||||
// the workaround is to invoke a kill from a different process group and this is done by starting detached
|
||||
// another idea is: use "ps --pid cp.pid -o pid=" to get the pid of the command and then send it signal directly
|
||||
cp.terminate = function () {
|
||||
cp.terminated = true; // hint for better debug message in 'exit'
|
||||
child_process.spawn('kill', ['-SIGTERM', cp.pid], { detached: true }, (error) => { if (error) debug(`${tag} could not terminate`, error); });
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user