From 68aa6ff33fe8eafb63664dd4da542932feea0456 Mon Sep 17 00:00:00 2001 From: lanyuanxiaoyao Date: Thu, 18 Sep 2025 09:30:47 +0800 Subject: [PATCH] =?UTF-8?q?refactor(server):=20=E6=9B=B4=E6=96=B0=20Java?= =?UTF-8?q?=20=E7=89=88=E6=9C=AC=E5=B9=B6=E4=BC=98=E5=8C=96=E5=81=9C?= =?UTF-8?q?=E6=AD=A2=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将 Java 版本从17.0.16+8 升级到 21.0.8+9 - 优化停止脚本以更准确地获取应用进程 ID - 添加使用 jps 命令获取进程 ID 的备选方案 --- leopard-server/bin/start.sh | 2 +- leopard-server/bin/stop.sh | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/leopard-server/bin/start.sh b/leopard-server/bin/start.sh index b3cd8e3..2c9086d 100644 --- a/leopard-server/bin/start.sh +++ b/leopard-server/bin/start.sh @@ -1,3 +1,3 @@ #!/bin/bash -nohup /home/ubuntu/jdk-17.0.16+8/bin/java -jar /home/ubuntu/app/leopard-server-1.0.0.jar --spring.profiles.active=build --spring.web.resources.static-locations=file:/home/ubuntu/app/dist --logging.parent=/home/ubuntu/app > /dev/null 2>&1 & +nohup /home/ubuntu/jdk-21.0.8+9/bin/java -jar /home/ubuntu/app/leopard-server-1.0.0.jar --spring.profiles.active=build --spring.web.resources.static-locations=file:/home/ubuntu/app/dist --logging.parent=/home/ubuntu/app > /dev/null 2>&1 & diff --git a/leopard-server/bin/stop.sh b/leopard-server/bin/stop.sh index 3d6023b..b16ecea 100644 --- a/leopard-server/bin/stop.sh +++ b/leopard-server/bin/stop.sh @@ -1,10 +1,17 @@ #!/bin/bash original_command="$0" -application_name="/home/ubuntu/app/leopard-server-1.0.0.jar" +application_name="leopard-server-1.0.0.jar" function get_pid() { - echo $(ps ef | grep "$application_name" | grep -v grep | awk '{ print $1 }') + ID=$(ps -ef | grep "$application_name" | grep -v grep | grep -v $original_command | awk '{ print $2 }') + if [[ -z "$ID" ]]; then + ID=$(ps aux | grep "$application_name" | grep -v grep | grep -v $original_command | awk '{print $2}') + if [[ -z "$ID" ]]; then + ID=$(/home/ubuntu/jdk-21.0.8+9/bin/jps -lmvV | grep "$application_name" | awk '{print $1}') + fi + fi + echo $ID } pid=$(get_pid) @@ -31,3 +38,4 @@ while (true); do fi sleep 1s done +