Ver Fonte

fix status.sh

apkipa há 1 mês atrás
pai
commit
e2fefd4ae5
1 ficheiros alterados com 11 adições e 9 exclusões
  1. 11 9
      nginx-ui-green/status.sh

+ 11 - 9
nginx-ui-green/status.sh

@@ -8,18 +8,20 @@ base_dir=$(
     pwd
 )
 cd $base_dir
-server_pid=$(ps -auxc | grep nginx-ui-green | grep -vE "grep|-Xmx700m" | awk '{print $2}')
+server_pid=$(pgrep -x nginx-ui || true)
 if [[ $server_pid == "" ]]; then
     echo "nginx-ui-green 未在运行"
 else
-    running_time=$(ps -o etime= -p "$server_pid")
-    ports=$(ss -tnlp | grep nginx-ui-green | awk '{print $4}')
+    for pid in $server_pid; do
+        running_time=$(ps -o etime= -p "$pid")
+        ports=$(ss -tnlp | grep nginx-ui | awk '{print $4}')
 
-    echo "nginx-ui-green 当前PID: $server_pid"
-    echo "当前运行时间: $running_time" | tr -s " "
-    echo "当前运行端口:"
-    for i in "$ports"; do
-        echo "$i"
-	break
+        echo "nginx-ui-green 当前PID: $pid"
+        echo "当前运行时间: $running_time" | tr -s " "
+        echo "当前运行端口:"
+        for port in $ports; do
+            echo "$port"
+            break
+        done
     done
 fi