Skip to content

Commit

Permalink
chore: udpdate community auto deploy (#203)
Browse files Browse the repository at this point in the history
  • Loading branch information
xigongdaEricyang authored Jan 30, 2023
1 parent 76118ce commit 7eef512
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 51 deletions.
25 changes: 16 additions & 9 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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}


2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand Down
53 changes: 23 additions & 30 deletions dashboard.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
}
Expand Down Expand Up @@ -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')
Expand Down
19 changes: 10 additions & 9 deletions scripts/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
8 changes: 6 additions & 2 deletions scripts/upload.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 7eef512

Please sign in to comment.