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,5 @@
#!/bin/bash
<#list services as service>
${currentPath}/deploy-${service}.sh
</#list>

View File

@@ -0,0 +1,5 @@
#!/bin/bash
<#list services as service>
${currentPath}/stop-${service}.sh
</#list>

View File

@@ -0,0 +1,30 @@
#!/bin/bash
<#--hosts=(
<#list hosts as host>
${host}
</#list>
)-->
datetime=`date +%Y%m%d%H%M%S`
log_path='${runtime.logPath}'
loki_url='${runtime.loki.servicePushUrl}'
zk_url='${runtime.zkUrl}'
security_authority='${runtime.security.authority}'
security_username='${runtime.security.username}'
security_darkcode='${runtime.security.darkcode}'
sync_clusters='${runtime.yarn.syncClusters}'
compaction_clusters='${runtime.yarn.compactionClusters}'
<#list hosts as host>
host=${host.ip}
echo "${info.name} ${host.ip} ${host.hostname} $datetime"
ssh $host 'bash -s' < ${currentPath}/stop.sh ${runtime.jarPath}/${info.name}.jar
<#if selectedHosts?seq_contains(host.ip)>
hostname=`ssh $host 'hostname'`
hostname_full=`ssh $host 'hostname -f'`
ssh $host "mkdir -p ${runtime.jarPath};curl ftp://yyy:QeY\!68\)4nH1@132.121.122.15:2222/${info.sourceJar} -o ${runtime.jarPath}/${info.name}.jar"
start_time=`date +%Y%m%d%H%M%S`
ssh $host "export JASYPT_ENCRYPTOR_PASSWORD='r#(R,P\"Dp^A47>WSn:Wn].gs/+\"v:q_Q*An~zF*g-@j@jtSTv5H/,S-3:R?r9R}.';nohup ${runtime.jdkPath} <#list environments?keys as key>-D${key}=${environments[key]?string} </#list>-jar ${runtime.jarPath}/${info.name}.jar<#noparse> --datetime=${datetime} --hostname=${hostname} --deploy.datetime=${datetime} --deploy.ip=${host} --deploy.hostname=${hostname} --deploy.hostname-full=${hostname_full} --deploy.start-time=${start_time} --logging.parent=${log_path} --loki.url=${loki_url} --spring.cloud.zookeeper.connect-string=${zk_url} --spring.security.meta.authority='${security_authority}' --spring.security.meta.username='${security_username}' --spring.security.meta.darkcode='${security_darkcode}' --yarn-cluster.sync-clusters=${sync_clusters} --yarn-cluster.compaction-clusters=${compaction_clusters}</#noparse> <#list arguments?keys as key>--${key}=${arguments[key]?string} </#list>> /dev/null 2>&1 &"
</#if>
echo ''
</#list>

View File

@@ -0,0 +1,17 @@
#!/bin/bash
hosts=(
<#list selectedHosts as host>
${host}
</#list>
)
mkdir -p logs/${info.name}
rm -rf logs/${info.name}/*
for host in <#noparse>${hosts[@]}</#noparse>
do
hostname=`ssh $host 'echo $HOSTNAME'`
echo "$host $hostname"
ssh $host "cat ${runtime.logPath}/${info.name}.log" > ${currentPath}/logs/${info.name}/$hostname.log
done

View File

@@ -0,0 +1,14 @@
#!/bin/bash
hosts=(
<#list hosts as host>
${host}
</#list>
)
for host in <#noparse>${hosts[@]}</#noparse>
do
hostname=`ssh $host 'echo $HOSTNAME'`
echo "$host $hostname"
ssh $host 'bash -s' < ${currentPath}/stop.sh ${runtime.jarPath}/${info.name}.jar
done