chore: add scripts and set tools

This commit is contained in:
Frank.R.Wu 2021-10-29 17:47:47 +08:00
parent 312b3336bb
commit 38970a3fca
5 changed files with 72 additions and 2 deletions

View File

@ -40,11 +40,20 @@ jar {
}
}
tasks.processResources.dependsOn(":web-client:copyToCluster")
tasks.processResources.setDuplicatesStrategy(DuplicatesStrategy.INCLUDE)
task prepareWebContent(type: Exec) {
if (System.properties['os.name'].toString().toLowerCase().contains('windows')) {
commandLine "rmdir", ".\\WebContent"
commandLine "mklink", "/j", "..\\router-frontend\\src", ".\\WebContent"
} else {
commandLine "rm", "./WebContent"
commandLine "ln", "-s", "../router-frontend/src", "./WebContent"
}
}
task copyScript(type: Copy) {
from("../script/") {
from("./script/") {
include 'ncstart.sh'
include 'ncstop.sh'
include 'ncconfig.json.template'

View File

@ -0,0 +1,7 @@
{
"servicePort": 21040,
"enableSsl": "./ssl/chained.pem:./ssl/domain.pem",
"disableDoRepo": false,
"disableLocalLhs": false,
"doipPort": 21042
}

28
script/ncstart.sh Normal file
View File

@ -0,0 +1,28 @@
#!/bin/bash
if [ ! -d "log/" ]; then
mkdir "log"
fi
bash ./ncstop.sh
time=$(date "+%Y_%m_%d_%H:%M:%S")
if [ -f "./log/nc.log" ]; then
echo "move log ./log/nc_${time}.log"
mv ./log/nc.log "./log/nc_${time}.log"
fi
if [ -f "./log/nc.err" ]; then
mv ./log/nc.err "./log/nc_${time}.err"
fi
# ps -ef | grep java | grep bdserver | grep NodeCenterServer | awk '{print $2}' |xargs kill -9
# ps -ef | grep java | grep bdcluster | grep NodeCenterServer | awk '{print $2}' |xargs kill -9
#-Dlog4j.configuration=file:
java -Dfile.encoding=UTF-8 -Dlog4j.configuration=file:./log4j.properties -cp "./libs/*:bdcluster.jar" org.bdware.server.NodeCenterServer 1 >./log/nc.log 2>./log/nc.err &
#以下可启用https/wss其中./ssl/xxx.pfx为ssl证书的路径:后面的123456是密码。
#java -Dfile.encoding=UTF-8 -cp "./libs/*:bdcluster.jar" org.bdware.server.NodeCenterServer -service-port=18002 -enable-ssl=./ssl/xxx.pfx:123456 -do-repo-ip=127.0.0.1 -do-repo-port=18098 1 > ./log/cm.log 2> ./log/cm.err &
echo $! >./PID

10
script/ncstop.sh Normal file
View File

@ -0,0 +1,10 @@
#!/bin/bash
if [ -a "./PID" ]; then
ls /proc/$(cat PID)/cmdline
if [ $? -eq 0 ]; then
kill -9 $(cat PID)
echo "shutdown old node center"
fi
rm ./PID
fi

16
script/updateCluster.sh Normal file
View File

@ -0,0 +1,16 @@
#!/bin/bash
#update WebContent
rm -r WebContent
rm ClusterWebContent.zip
wget https://public.internetapi.cn/releases/bdcontract/newest/ClusterWebContent.zip
unzip -d WebContent ClusterWebContent.zip
#update bdcluster.jar
rm -r libs
rm bdcluster.jar
wget https://public.internetapi.cn/releases/bdcontract/newest/bdcluster.zip
unzip bdcluster.zip
echo "Automatically Restarting Cluster"
sh ncstart.sh
echo "Done!"