|
|
|
@ -241,6 +241,30 @@ class CLI {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/explicit-module-boundary-types
|
|
|
|
|
|
|
|
killThread = (thread:any): void => {
|
|
|
|
|
|
|
|
const killArray = [
|
|
|
|
|
|
|
|
'SIGKILL',
|
|
|
|
|
|
|
|
'SIGHUP',
|
|
|
|
|
|
|
|
'SIGTERM',
|
|
|
|
|
|
|
|
'SIGINT',
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
thread.kill();
|
|
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
|
|
|
// err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
killArray.forEach((com: string) => {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
thread.kill(com);
|
|
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
|
|
|
// err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
runCli = async (): Promise<{
|
|
|
|
runCli = async (): Promise<{
|
|
|
|
cliExitCode: number,
|
|
|
|
cliExitCode: number,
|
|
|
|
errorLogFull: string[],
|
|
|
|
errorLogFull: string[],
|
|
|
|
@ -249,7 +273,6 @@ class CLI {
|
|
|
|
|
|
|
|
|
|
|
|
const errorLogFull: string[] = [];
|
|
|
|
const errorLogFull: string[] = [];
|
|
|
|
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
|
|
|
|
this.config.jobLog(`Running ${this.config.cli} ${this.config.spawnArgs.join(' ')}`);
|
|
|
|
this.config.jobLog(`Running ${this.config.cli} ${this.config.spawnArgs.join(' ')}`);
|
|
|
|
const cliExitCode: number = await new Promise((resolve) => {
|
|
|
|
const cliExitCode: number = await new Promise((resolve) => {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
@ -257,16 +280,26 @@ class CLI {
|
|
|
|
const spawnArgs = this.config.spawnArgs.map((row) => row.trim()).filter((row) => row !== '');
|
|
|
|
const spawnArgs = this.config.spawnArgs.map((row) => row.trim()).filter((row) => row !== '');
|
|
|
|
const thread = childProcess.spawn(this.config.cli, spawnArgs, opts);
|
|
|
|
const thread = childProcess.spawn(this.config.cli, spawnArgs, opts);
|
|
|
|
|
|
|
|
|
|
|
|
thread.stdout.on('data', (data: string) => {
|
|
|
|
process.on('exit', () => {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
|
|
|
|
console.log('Main thread exiting, cleaning up running CLI');
|
|
|
|
|
|
|
|
this.killThread(thread);
|
|
|
|
|
|
|
|
} catch (err) {
|
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
// console.log(data.toString());
|
|
|
|
console.log('Error running cliUtils on Exit function');
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
|
|
|
|
console.log(err);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
thread.stdout.on('data', (data: string) => {
|
|
|
|
errorLogFull.push(data.toString());
|
|
|
|
errorLogFull.push(data.toString());
|
|
|
|
this.parseOutput(data);
|
|
|
|
this.parseOutput(data);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
thread.stderr.on('data', (data: string) => {
|
|
|
|
thread.stderr.on('data', (data: string) => {
|
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
// console.log(data.toString());
|
|
|
|
|
|
|
|
errorLogFull.push(data.toString());
|
|
|
|
errorLogFull.push(data.toString());
|
|
|
|
this.parseOutput(data);
|
|
|
|
this.parseOutput(data);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|