From 38970a3fcaec836e799ddebd2a67301fe83ab9fd Mon Sep 17 00:00:00 2001 From: "Frank.R.Wu" Date: Fri, 29 Oct 2021 17:47:47 +0800 Subject: [PATCH] chore: add scripts and set tools --- build.gradle | 13 +++++++++++-- script/ncconfig.json.template | 7 +++++++ script/ncstart.sh | 28 ++++++++++++++++++++++++++++ script/ncstop.sh | 10 ++++++++++ script/updateCluster.sh | 16 ++++++++++++++++ 5 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 script/ncconfig.json.template create mode 100644 script/ncstart.sh create mode 100644 script/ncstop.sh create mode 100644 script/updateCluster.sh diff --git a/build.gradle b/build.gradle index 5e7542f..5376997 100644 --- a/build.gradle +++ b/build.gradle @@ -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' diff --git a/script/ncconfig.json.template b/script/ncconfig.json.template new file mode 100644 index 0000000..d0a236e --- /dev/null +++ b/script/ncconfig.json.template @@ -0,0 +1,7 @@ +{ + "servicePort": 21040, + "enableSsl": "./ssl/chained.pem:./ssl/domain.pem", + "disableDoRepo": false, + "disableLocalLhs": false, + "doipPort": 21042 +} \ No newline at end of file diff --git a/script/ncstart.sh b/script/ncstart.sh new file mode 100644 index 0000000..2d236f5 --- /dev/null +++ b/script/ncstart.sh @@ -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 diff --git a/script/ncstop.sh b/script/ncstop.sh new file mode 100644 index 0000000..17fb961 --- /dev/null +++ b/script/ncstop.sh @@ -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 diff --git a/script/updateCluster.sh b/script/updateCluster.sh new file mode 100644 index 0000000..293eb0b --- /dev/null +++ b/script/updateCluster.sh @@ -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!"