改用ps-ef识别部署进程

This commit is contained in:
wkc
2026-04-01 10:49:25 +08:00
parent f8b2bf2afc
commit 3a8f37f547
3 changed files with 48 additions and 5 deletions

View File

@@ -196,12 +196,12 @@ is_managed_backend_pid() {
return 1
fi
args=$(ps -o args= -p "$pid" 2>/dev/null || true)
if [ -z "${args:-}" ]; then
process_line=$(ps -ef | awk -v target_pid="$pid" '$2 == target_pid {print $0}')
if [ -z "${process_line:-}" ]; then
return 1
fi
case "$args" in
case "$process_line" in
*"$BACKEND_MARKER"*"$BACKEND_JAR_TARGET"*|*"$BACKEND_JAR_TARGET"*"$BACKEND_MARKER"*)
return 0
;;
@@ -220,7 +220,11 @@ collect_backend_pids() {
fi
fi
marker_pids=$(pgrep -f "$BACKEND_MARKER" 2>/dev/null || true)
marker_pids=$(
ps -ef | awk -v marker="$BACKEND_MARKER" -v jar="$BACKEND_JAR_TARGET" '
index($0, marker) > 0 && index($0, jar) > 0 {print $2}
'
)
if [ -n "${marker_pids:-}" ]; then
for pid in $marker_pids; do
if is_managed_backend_pid "$pid"; then
@@ -331,7 +335,6 @@ main() {
require_dir "$FRONTEND_DIR"
require_command unzip
require_command find
require_command pgrep
require_command ps
require_command nohup
require_port_command