修改启动脚本

This commit is contained in:
Tian jianyong 2025-10-17 10:44:34 +08:00
parent b3fbdba4e1
commit a47fc1ee34

66
qaup.sh
View File

@ -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"