Skip to content

Commit

Permalink
fix grep and head
Browse files Browse the repository at this point in the history
  • Loading branch information
willnode committed Jan 7, 2024
1 parent 3f49b36 commit d3748f2
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/executor/logman.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,13 @@ class LogmanExecutor {
a[b.name] = x.map(y => y.pid).filter(y => typeof y === "number");
return a;
}, {});
let head = `List of passenger processes running:\n`;
head += JSON.stringify(procs, null, 2);
head += `\n------------------------\n`;
console.log(head);
let pids = Object.values(procs).flatMap(x => x).join('\\|');
const pes = await spawnSudoUtil("SHELL_SUDO", ["root",
"bash", "-c", `grep -w "\\^App \\(${pids}\\)" "${this.PASSENGERLOG}" | tail -n ${n}`
let pes = await spawnSudoUtil("SHELL_SUDO", ["root",
"bash", "-c", `grep -w "\\(^App\\|process\\) \\(${pids}\\)" "${this.PASSENGERLOG}" | tail -n ${n}`
]);
if (pes.code == 0) {
pes.stdout = head + pes.stdout;
// @ts-ignore
pes.processes = procs;
}
return pes;
default:
Expand Down

0 comments on commit d3748f2

Please sign in to comment.