From a47fc1ee34e6e446315c2ee21fa33605e03c1830 Mon Sep 17 00:00:00 2001 From: Tian jianyong <11429339@qq.com> Date: Fri, 17 Oct 2025 10:44:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=90=AF=E5=8A=A8=E8=84=9A?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- qaup.sh | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) diff --git a/qaup.sh b/qaup.sh index 395f2e3d..b68619f9 100644 --- a/qaup.sh +++ b/qaup.sh @@ -39,7 +39,71 @@ function start() if [ -f "$ENV_FILE" ]; then echo "Loading environment variables from $ENV_FILE" # 导出环境变量,忽略注释行和空行 - export $(cat $ENV_FILE | grep -v '^#' | grep -v '^$' | xargs) + export $(grep -v '^#' $ENV_FILE | grep -v '^ + + echo "Starting $AppName with profile: $SPRING_PROFILES" + + # 启动应用,指定Spring Profile + nohup java $JVM_OPTS -jar $AppName --spring.profiles.active=$SPRING_PROFILES > /dev/null 2>&1 & + + echo "Start $AppName success..." + fi +} + +function stop() +{ + echo "Stop $AppName" + + PID="" + query(){ + PID=`ps -ef |grep java|grep $AppName|grep -v grep|awk '{print $2}'` + } + + query + if [ x"$PID" != x"" ]; then + kill -TERM $PID + echo "$AppName (pid:$PID) exiting..." + while [ x"$PID" != x"" ] + do + sleep 1 + query + done + echo "$AppName exited." + else + echo "$AppName already stopped." + fi +} + +function restart() +{ + stop + sleep 2 + start +} + +function status() +{ + PID=`ps -ef |grep java|grep $AppName|grep -v grep|wc -l` + if [ $PID != 0 ];then + echo "$AppName is running..." + else + echo "$AppName is not running..." + fi +} + +case $1 in + start) + start;; + stop) + stop;; + restart) + restart;; + status) + status;; + *) + echo -e "\033[0;31m 未知操作 \033[0m \033[0;34m {start|stop|restart|status} \033[0m" +esac + | xargs) echo "Environment variables loaded successfully" else echo "Warning: $ENV_FILE not found, using default configuration"