This commit is contained in:
yuzchen 2024-01-24 09:39:50 +08:00
parent d2f09bc7c8
commit f96aa14b59
1 changed files with 16 additions and 6 deletions

View File

@ -1,13 +1,23 @@
#!/bin/sh #!/bin/sh
# 找到Springboot项目对应的进程id # 找到Springboot项目对应的进程id
P_ID=`ps -ef | grep -w demo4bonus-0.0.1 | grep -v "grep" | awk '{print $2}'` P_ID=$(pgrep -f "demo4bonus-0.0.1")
# 如果该项目已经在服务器上启动则kill掉 # 如果该项目已经在服务器上启动则kill掉
echo “原应用程序进程id$P_ID echo "原应用程序进程id$P_ID"
if [ "$P_ID" == "" ]; then if [ -z "$P_ID" ]; then
echo "===service process doest not exist" echo "==Demo service process does not exist"
else else
kill -9 $P_ID # 尝试优雅地关闭应用程序
echo "service killed success" kill -SIGTERM "$P_ID"
wait "$P_ID" 2>/dev/null
# 检查进程是否仍在运行
if ! ps -p "$P_ID" > /dev/null; then
echo "Demo service process was terminated gracefully"
else
# 如果优雅关闭失败,则强制杀死进程
kill -SIGKILL "$P_ID"
echo "Demo service process was killed forcefully"
fi
fi fi
echo "授权" echo "授权"