Skip to content

Commit

Permalink
Fix process output test
Browse files Browse the repository at this point in the history
  • Loading branch information
willnode committed May 25, 2024
1 parent 184b5dc commit 93a5114
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/executor/logman.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class LogmanExecutor {
return {
code: 255,
stderr: 'No access log found',
stdout: '',
}
}
return await spawnSudoUtil("SHELL_SUDO", ["root",
Expand All @@ -35,14 +36,18 @@ class LogmanExecutor {
return {
code: 255,
stderr: 'No error log found',
stdout: '',
}
}
return await spawnSudoUtil("SHELL_SUDO", ["root",
"tail", "-n", n, domain['Error log']]);
case 'passenger':
const user = domain['Username'];
const procs = await this.getPassengerPids(user);
let pids = Object.values(procs).flatMap(x => x).join('\\|');
if (procs.code !== 0) {
return procs;
}
let pids = Object.values(procs.stdout).flatMap(x => x).join('\\|');
let pes = await spawnSudoUtil("SHELL_SUDO", ["root",
"bash", "-c", `grep -w "\\(^App\\|process\\) \\(${pids}\\)" "${this.PASSENGERLOG}" | tail -n ${n}`
]);
Expand All @@ -54,7 +59,8 @@ class LogmanExecutor {
default:
return {
code: 255,
stderr: 'Unknown log type ' + type
stderr: 'Unknown log type ' + type,
stdout: '',
}
}
}
Expand All @@ -64,10 +70,13 @@ class LogmanExecutor {
async restartPassenger(domain) {
const user = domain['Username'];
const procs = await this.getPassengerPids(user);
let pids = Object.values(procs).flatMap(x => x).join(' ');
if (procs.code !== 0) {
return procs.stderr;
}
let pids = Object.values(procs.stdout).flatMap(x => x);
if (pids) {
await spawnSudoUtil("SHELL_SUDO", ["root",
"bash", "-c", `kill -9 ${pids}`
"kill", "-9", ...pids
]);
return "Sent SIGKILL to processes " + pids;
}
Expand All @@ -90,6 +99,7 @@ class LogmanExecutor {
return {
code: 255,
stderr: 'No passenger app is found or it\'s not initialized yet',
stdout: '',
}
}
const parser = new XMLParser();
Expand All @@ -116,7 +126,11 @@ class LogmanExecutor {
a[b.name] = x.map(y => y.pid).filter(y => typeof y === "number");
return a;
}, {});
return procs;
return {
code: 0,
stderr: '',
stdout: procs
};
}
}

Expand Down

0 comments on commit 93a5114

Please sign in to comment.