Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export async function findNodeProcess(filterFn?: FilterFunction): Promise<NodePr
const command = isWindows ?
'wmic Path win32_process Where "Name = \'node.exe\'" Get CommandLine,ProcessId' :
// command, cmd are alias of args, not POSIX standard, so we use args
'ps -wweo "pid,args"';
'command -v ps >/dev/null 2>&1 && ps --help 2>&1 | grep -q BusyBox && ps -o "pid,args" || ps -wweo "pid,args"';
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The ps -o "pid,args" command for BusyBox is likely insufficient for two reasons:

  1. Missing all-process flag: By default, BusyBox ps often only shows processes associated with the current terminal and user. To find background server processes (master and workers), you should use -A or -e to ensure all processes are listed.
  2. Truncation: BusyBox ps output is typically truncated to the terminal width. Adding the -w flag is necessary to ensure the full command line is captured, which is critical for the filterFn and the logic in stop.ts that relies on matching specific strings (like start-cluster) in the process arguments.

I suggest using ps -w -A -o pid,args for the BusyBox case.

Suggested change
'command -v ps >/dev/null 2>&1 && ps --help 2>&1 | grep -q BusyBox && ps -o "pid,args" || ps -wweo "pid,args"';
'command -v ps >/dev/null 2>&1 && ps --help 2>&1 | grep -q BusyBox && ps -w -A -o pid,args || ps -wweo "pid,args"';

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alpine(buxybox) the ps command does not include the -w and -A parameter.

const stdio = await runScript(command, { stdio: 'pipe' });
const processList = stdio.stdout!.toString().split('\n')
.reduce<NodeProcess[]>((arr, line) => {
Expand Down