Fix onExit(): emits a object containing exitCode and signal

This commit is contained in:
Bryan Ashby 2023-10-12 20:21:49 -06:00
parent b87ff51160
commit ca985dd2cb
4 changed files with 21 additions and 18 deletions

View File

@ -214,11 +214,11 @@ module.exports = class ArchiveUtil {
}
});
proc.onExit(exitCode => {
proc.onExit(exitEvent => {
return cb(
exitCode
? Errors.ExternalProcess(
`${action} failed with exit code: ${exitCode}`
`${action} failed with exit code: ${exitEvent.exitCode}`
)
: err
);
@ -358,10 +358,10 @@ module.exports = class ArchiveUtil {
output += data;
});
proc.onExit(exitCode => {
if (exitCode) {
proc.onExit(exitEvent => {
if (exitEvent.exitCode) {
return cb(
Errors.ExternalProcess(`List failed with exit code: ${exitCode}`)
Errors.ExternalProcess(`List failed with exit code: ${exitEvent.exitCode}`)
);
}

View File

@ -113,9 +113,10 @@ module.exports = class Door {
spawnOptions
);
prePty.onExit(exitCode => {
prePty.onExit(exitEvent => {
const {exitCode, signal} = exitEvent;
this.client.log.info(
{ exitCode: exitCode },
{ exitCode, signal },
'Door pre-command exited'
);
return callback(null);
@ -165,7 +166,7 @@ module.exports = class Door {
this.doorPty.onData(this.doorDataHandler.bind(this));
this.doorPty.onExit(exitCode => {
this.doorPty.onExit( (/*exitEvent*/) => {
return this.restoreIo(this.doorPty);
});
} else if ('socket' === this.io) {
@ -178,8 +179,9 @@ module.exports = class Door {
);
}
this.doorPty.onExit(exitCode => {
this.client.log.info({ exitCode: exitCode }, 'Door exited');
this.doorPty.onExit(exitEvent => {
const {exitCode, signal} = exitEvent;
this.client.log.info({ exitCode, signal }, 'Door exited');
if (this.sockServer) {
this.sockServer.close();

View File

@ -167,17 +167,17 @@ class ScheduledEvent {
return cb(e);
}
proc.onExit(exitCode => {
if (exitCode) {
proc.onExit(exitEvent => {
if (exitEvent.exitCode) {
Log.warn(
{ eventName: this.name, action: this.action, exitCode: exitCode },
{ eventName: this.name, action: this.action, exitCode: exitEvent.exitCode },
'Bad exit code while performing scheduled event action'
);
}
return cb(
exitCode
exitEvent.exitCode
? Errors.ExternalProcess(
`Bad exit code while performing scheduled event action: ${exitCode}`
`Bad exit code while performing scheduled event action: ${exitEvent.exitCode}`
)
: null
);

View File

@ -485,9 +485,10 @@ exports.getModule = class TransferFileModule extends MenuModule {
}
});
externalProc.onExit(exitCode => {
externalProc.onExit(exitEvent => {
const {exitCode, signal} = exitEvent;
this.client.log.debug(
{ cmd: cmd, args: args, exitCode: exitCode },
{ cmd: cmd, args: args, exitCode, signal },
'Process exited'
);