Skip to content

Commit bc1a0f7

Browse files
fix(scripts): findNodeProcess compatible busybox ps command (#5874)
Fixed an error when executing the `npm stop` command within the Alpine Node.js container in Kubernetes. Error ``` $ npm stop > nfb@1.0.0 stop > egg-scripts stop --title=NFB [egg-scripts] stopping egg application with --title=NFB ⚠️ RunScriptError: Run "sh -c ps -wweo "pid,args"" error, exit code 1 ⚠️ Command Error, enable `DEBUG=common-bin` for detail ``` The `busybox ps` no other parameter ``` # ps --help BusyBox v1.37.0 (2025-08-05 16:40:33 UTC) multi-call binary. Usage: ps [-o COL1,COL2=HEADER] [-T] Show list of processes -o COL1,COL2=HEADER Select columns for display -T Show threads ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved Node process detection on BusyBox-based and other non-standard Linux environments by enhancing runtime command probing and conditional handling, yielding more reliable process listing and detection across diverse systems. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: nAnderYang <nander@qq.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent a8a7572 commit bc1a0f7

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

tools/scripts/src/helper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export async function findNodeProcess(filterFn?: FilterFunction): Promise<NodePr
1515
const command = isWindows
1616
? 'wmic Path win32_process Where "Name = \'node.exe\'" Get CommandLine,ProcessId'
1717
: // command, cmd are alias of args, not POSIX standard, so we use args
18-
'ps -wweo "pid,args"';
18+
'ps --help 2>&1 | grep -q BusyBox && ps -o "pid,args" || ps -wweo "pid,args"';
1919
const stdio = await runScript(command, { stdio: 'pipe' });
2020
const processList = stdio
2121
.stdout!.toString()

0 commit comments

Comments
 (0)