From 6d15224a08ebf8795b280f9c48e00126fd8f24b4 Mon Sep 17 00:00:00 2001 From: rivery Date: Mon, 30 Jan 2023 14:16:52 +0800 Subject: [PATCH] chore: udpdate community auto deploy chore: update status all implementaion chore: update oss dir chore: update workflow --- .github/workflows/nightly.yml | 25 +++++++++++------ .github/workflows/release.yml | 2 +- dashboard.service.js | 53 +++++++++++++++-------------------- scripts/package.sh | 19 +++++++------ scripts/upload.sh | 8 ++++-- 5 files changed, 56 insertions(+), 51 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 2ccf3be1..f3943779 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -1,5 +1,12 @@ name: Dashboard Mannually Package -on: workflow_dispatch +on: + workflow_dispatch: + version: + required: false + type: string + description: "The version of the package(default use package.json version)" +env: + VERSION: ${{ github.event.inputs.version }} jobs: package: name: build package @@ -27,17 +34,17 @@ jobs: repository: vesoft-inc/nebula-http-gateway path: source/nebula-http-gateway ref: v3.1.4 - - uses: actions/setup-go@v2 - with: - go-version: '^1.13.1' - - uses: actions/setup-node@v2 - with: - node-version: '14' + # - uses: actions/setup-go@v2 + # with: + # go-version: '^1.13.1' + # - uses: actions/setup-node@v2 + # with: + # node-version: '14' - name: ls run: ls -a - name: Package - run: bash ./source/nebula-dashboard/scripts/package.sh source/nebula-dashboard source/nebula-http-gateway true ${{ matrix.cpu_arch[0] }} ${{ secrets.GA_ID }} + run: bash ./source/nebula-dashboard/scripts/package.sh source/nebula-dashboard source/nebula-http-gateway ${{ matrix.cpu_arch[0] }} ${{ secrets.GA_ID }} ${VERSION} - name: Upload to OSS - run: bash ./source/nebula-dashboard/scripts/upload.sh ${{ secrets.OSS_ENDPOINT }} ${{ secrets.OSS_ID }} ${{ secrets.OSS_SECRET }} ${{ secrets.OSS_TEST_URL }} + run: bash ./source/nebula-dashboard/scripts/upload.sh ${{ secrets.OSS_ENDPOINT }} ${{ secrets.OSS_ID }} ${{ secrets.OSS_SECRET }} ${{ secrets.OSS_TEST_URL }}community/ ${VERSION} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0b523069..9033ba78 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -39,7 +39,7 @@ jobs: - name: ls run: ls -a - name: Package - run: bash ./source/nebula-dashboard/scripts/package.sh source/nebula-dashboard source/nebula-http-gateway false ${{ matrix.cpu_arch[0] }} ${{ secrets.GA_ID }} + run: bash ./source/nebula-dashboard/scripts/package.sh source/nebula-dashboard source/nebula-http-gateway ${{ matrix.cpu_arch[0] }} ${{ secrets.GA_ID }} - name: Upload to OSS run: bash ./source/nebula-dashboard/scripts/upload.sh ${{ secrets.OSS_ENDPOINT }} ${{ secrets.OSS_ID }} ${{ secrets.OSS_SECRET }} ${{ secrets.OSS_URL }} diff --git a/dashboard.service.js b/dashboard.service.js index a2564cf4..ed736200 100755 --- a/dashboard.service.js +++ b/dashboard.service.js @@ -212,23 +212,30 @@ function startService(type) { } } +function getTargetPort(type) { + let tartgetPort; + switch (type) { + case COMPONETS.GATEWAY: + tartgetPort = config.gateway.port; + break; + case COMPONETS.STATS_EXPORTER: + tartgetPort = config['stats-exporter'].port; + break; + case COMPONETS.PROMETHEUS: + tartgetPort = config.prometheus.port; + break; + case COMPONETS.WEBSERVER: + tartgetPort = config.port; + break; + } + return tartgetPort; +} + function stopService(type) { makeDirIfAbsent('logs') try { - switch (type) { - case COMPONETS.GATEWAY: - execSync(`kill -9 $(lsof -i:${config.gateway.port} -t)`) - break; - case COMPONETS.STATS_EXPORTER: - execSync(`kill -9 $(lsof -i:${config['stats-exporter'].port} -t)`) - break; - case COMPONETS.PROMETHEUS: - execSync(`kill -9 $(lsof -i:${config.prometheus.port} -t)`) - break; - case COMPONETS.WEBSERVER: - execSync(`kill -9 $(lsof -i:${config.port} -t)`) - break; - } + const tartgetPort = getTargetPort(type); + tartgetPort ?? execSync(`sudo netstat -anp | grep ${tartgetPort} | awk '{print $7}' | awk -F '/' '{print $1}' | xargs kill -9`) } catch (error) { // ERROR(`${type} service is exited already`) } @@ -265,23 +272,9 @@ function stopServices(type) { } function statusService(type) { - let command = '' - switch (type) { - case COMPONETS.GATEWAY: - command = `lsof -i:${config.gateway.port} -t` - break; - case COMPONETS.STATS_EXPORTER: - command = `lsof -i:${config['stats-exporter'].port} -t` - break; - case COMPONETS.PROMETHEUS: - command = `lsof -i:${config.prometheus.port} -t` - break; - case COMPONETS.WEBSERVER: - command = `lsof -i:${config.port} -t` - break; - } + const tartgetPort = getTargetPort(type); try { - const result = execSync(command, { encoding: 'utf-8' }); + const result = tartgetPort ?? execSync(`sudo netstat -nlp | grep ${tartgetPort} | awk '{print $7}' | awk -F '/' '{print $1}'`, { encoding: 'utf-8' }); INFO(type, 'service is running in', result) } catch (error) { ERROR(type, 'is exited') diff --git a/scripts/package.sh b/scripts/package.sh index 8477aff4..e281149d 100644 --- a/scripts/package.sh +++ b/scripts/package.sh @@ -5,9 +5,9 @@ set -ex DIR=`pwd` DASHBOARD=$DIR/$1 GATEWAY=$DIR/$2 -NIGHTLY=$3 -CPU_ARCH=$4 -GH_ID=$5 +CPU_ARCH=$3 +GH_ID=$4 +SPEC_VERSION=$5 # build target dir @@ -57,7 +57,12 @@ mv $DASHBOARD/docker-compose/docker-compose.yaml $TARGET/ ### NebulaGraph Dashboard relative ### cd $DASHBOARD -VERSION=`cat package.json | grep '"version":' | awk 'NR==1{print $2}' | awk -F'"' '{print $2}'` +VERSION= +if [ ! $SPEC_VERSION ];then + VERSION=`cat package.json | grep '"version":' | awk 'NR==1{print $2}' | awk -F'"' '{print $2}'` +else + VERSION=$SPEC_VERSION +fi bash $DASHBOARD/scripts/setEventTracking.sh $GH_ID npm install --unsafe-perm @@ -72,8 +77,4 @@ cp -r $DASHBOARD/vendors/config-release.yaml $TARGET/config.yaml ### tar cd $DIR -if [[ $NIGHTLY == "true" ]];then - tar -czf nebula-dashboard-nightly.tar.gz nebula-dashboard -else - tar -czf nebula-dashboard-$VERSION.x86_64.tar.gz nebula-dashboard -fi +tar -czf nebula-dashboard-$VERSION.x86_64.tar.gz nebula-dashboard diff --git a/scripts/upload.sh b/scripts/upload.sh index 388ea404..c1844f81 100644 --- a/scripts/upload.sh +++ b/scripts/upload.sh @@ -1,8 +1,12 @@ set -ex - +SPEC_VERSION=$5 DIR=`pwd` DASHBOARD=$DIR/source/nebula-dashboard cd $DASHBOARD -VERSION=`cat package.json | grep '"version":' | awk 'NR==1{print $2}' | awk -F'"' '{print $2}'` +if [ ! $SPEC_VERSION ];then + VERSION=`cat packages/${PACKAGE_NAME}/package.json | grep '"version":' | awk 'NR==1{print $2}' | awk -F'"' '{print $2}'` +else + VERSION=$SPEC_VERSION +fi cd $DIR ossutil64 -e $1 -i $2 -k $3 -f cp ./ $4${VERSION} --include "nebula-dashboard-*.tar.gz" --only-current-dir -r \ No newline at end of file