執行脚本

This commit is contained in:
haozq 2024-02-28 18:26:07 +08:00
parent 97b30fb2ca
commit b6550bfcbd
3 changed files with 102 additions and 0 deletions

View File

@ -0,0 +1,34 @@
#!/bin/sh
# 找到Springboot项目对应的进程id
P_ID=$(pgrep -f "securitycontrol-auth")
# 如果该项目已经在服务器上启动则kill掉
echo "原应用程序进程id$P_ID"
if [ -z "$P_ID" ]; then
echo "==Demo service process does not exist"
else
# 尝试优雅地关闭应用程序
kill -9 "$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 -9 "$P_ID"
echo "Demo service process was killed forcefully"
fi
fi
echo "授权"
# 让root用户对jar包持有读执行的权限
chmod 777 /opt/jar/hb/zhgd/jar/auth/securitycontrol-auth.jar
echo "执行"
# cd /opt/webapps/
# 目标服务器后台方式启动jar包
#nohup /usr/local/jdk-17.0.9/bin/java -jar /opt/webapps/demo4bonus-0.0.1-SNAPSHOT.jar >/dev/null 2>&1 &
nohup java -jar securitycontrol-auth.jar >/opt/jar/hb/zhgd/jar/logs/securitycontrol-auth.log 2>&1 &
echo "启动成功"

View File

@ -0,0 +1,34 @@
#!/bin/sh
# 找到Springboot项目对应的进程id
P_ID=$(pgrep -f "securitycontrol-gateway")
# 如果该项目已经在服务器上启动则kill掉
echo "原应用程序进程id$P_ID"
if [ -z "$P_ID" ]; then
echo "==Demo service process does not exist"
else
# 尝试优雅地关闭应用程序
kill -9 "$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 -9 "$P_ID"
echo "Demo service process was killed forcefully"
fi
fi
echo "授权"
# 让root用户对jar包持有读执行的权限
chmod 777 /opt/jar/hb/zhgd/jar/gateway/securitycontrol-gateway.jar
echo "执行"
# cd /opt/webapps/
# 目标服务器后台方式启动jar包
#nohup /usr/local/jdk-17.0.9/bin/java -jar /opt/webapps/demo4bonus-0.0.1-SNAPSHOT.jar >/dev/null 2>&1 &
nohup java -jar securitycontrol-gateway.jar >/opt/jar/hb/zhgd/jar/logs/securitycontrol-gateway.log 2>&1 &
echo "启动成功"

View File

@ -0,0 +1,34 @@
#!/bin/sh
# 找到Springboot项目对应的进程id
P_ID=$(pgrep -f "securitycontrol-system")
# 如果该项目已经在服务器上启动则kill掉
echo "原应用程序进程id$P_ID"
if [ -z "$P_ID" ]; then
echo "==Demo service process does not exist"
else
# 尝试优雅地关闭应用程序
kill -9 "$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 -9 "$P_ID"
echo "Demo service process was killed forcefully"
fi
fi
echo "授权"
# 让root用户对jar包持有读执行的权限
chmod 777 /opt/jar/hb/zhgd/jar/system/securitycontrol-system.jar
echo "执行"
# cd /opt/webapps/
# 目标服务器后台方式启动jar包
#nohup /usr/local/jdk-17.0.9/bin/java -jar /opt/webapps/demo4bonus-0.0.1-SNAPSHOT.jar >/dev/null 2>&1 &
nohup java -jar securitycontrol-system.jar >/opt/jar/hb/zhgd/jar/logs/securitycontrol-system.log 2>&1 &
echo "启动成功"