refactor(cli): 优化脚本 增加command脚本的生成

This commit is contained in:
2024-02-27 10:44:20 +08:00
parent 5ecc3daac0
commit 73f0c4c82c
12 changed files with 146 additions and 52 deletions

View File

@@ -0,0 +1,40 @@
#!/bin/bash
original_command="$0"
application_name="$1"
function get_pid() {
ID=$(ps -ef | grep "$application_name" | grep -v grep | grep -v $original_command | awk '{ print $2 }')
if [[ -z "$ID" ]]; then
ID=$(ps -C java -f --width 1000 | 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}')
fi
fi
echo ${ID}
}
pid=$(get_pid)
if [[ -z "$pid" ]]; then
echo "Application is already stopped."
exit 0
fi
echo "Stopping $pid..."
kill ${pid}
LOOPS=0
while (true); do
cpid=$(get_pid)
if [[ -z "$cpid" ]]; then
echo "Oook! cost:$LOOPS"
break
fi
LOOPS=$(($LOOPS+1))
if [[ $(($LOOPS%15)) -eq 0 ]]; then
echo "Wait timeout, try to force kill ${pid}..."
kill -9 ${pid}
fi
sleep 1s
done

View File

@@ -0,0 +1,10 @@
#!/bin/bash
datetime=`date +%Y%m%d%H%M%S`
log_path='${runtime.logPath}'
loki_url='${runtime.loki.servicePushUrl}'
mkdir -p ${runtime.jarPath}
export JASYPT_ENCRYPTOR_PASSWORD='r#(R,P\"Dp^A47>WSn:Wn].gs/+\"v:q_Q*An~zF*g-@j@jtSTv5H/,S-3:R?r9R}.'
${runtime.jdkPath} <#noparse>-Ddatetime=${datetime} -Dhostname=${HOSTNAME} -Dlogging.parent=${log_path} -Dloki.url=${loki_url}</#noparse> -Dspring.profiles.include=default,b12 -jar ${runtime.jarPath}/service-command.jar<#if directly> $@</#if>

View File

@@ -0,0 +1,3 @@
#!/bin/bash
curl ftp://yyy:QeY\!68\)4nH1@132.121.122.15:2222/command-1.0.0-SNAPSHOT.jar -o ${runtime.jarPath}/service-command.jar