mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-12 03:10:26 +08:00
实现监控节点在线状态
This commit is contained in:
87
build/build-demo.sh
Executable file
87
build/build-demo.sh
Executable file
@@ -0,0 +1,87 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
function build() {
|
||||||
|
ROOT=$(dirname $0)
|
||||||
|
NAME="edge-admin"
|
||||||
|
DIST=$ROOT/"../dist/${NAME}"
|
||||||
|
OS=${1}
|
||||||
|
ARCH=${2}
|
||||||
|
|
||||||
|
if [ -z $OS ]; then
|
||||||
|
echo "usage: build.sh OS ARCH"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
if [ -z $ARCH ]; then
|
||||||
|
echo "usage: build.sh OS ARCH"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
VERSION=$(lookup-version $ROOT/../internal/const/const.go)
|
||||||
|
ZIP="${NAME}-${OS}-${ARCH}-v${VERSION}.zip"
|
||||||
|
|
||||||
|
# check edge-api
|
||||||
|
APINodeVersion=$(lookup-version $ROOT"/../../EdgeAPI/internal/const/const.go")
|
||||||
|
echo "building edge-api v${APINodeVersion} ..."
|
||||||
|
EDGE_API_BUILD_SCRIPT=$ROOT"/../../EdgeAPI/build/build.sh"
|
||||||
|
if [ ! -f $EDGE_API_BUILD_SCRIPT ]; then
|
||||||
|
echo "unable to find edge-api build script 'EdgeAPI/build/build.sh'"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd $ROOT"/../../EdgeAPI/build"
|
||||||
|
echo "=============================="
|
||||||
|
./build.sh $OS $ARCH
|
||||||
|
echo "=============================="
|
||||||
|
cd -
|
||||||
|
|
||||||
|
# create dir & copy files
|
||||||
|
echo "copying ..."
|
||||||
|
if [ ! -d $DIST ]; then
|
||||||
|
mkdir $DIST
|
||||||
|
mkdir $DIST/bin
|
||||||
|
mkdir $DIST/configs
|
||||||
|
mkdir $DIST/logs
|
||||||
|
fi
|
||||||
|
|
||||||
|
cp -R $ROOT/../web $DIST/
|
||||||
|
rm -f $DIST/web/tmp/*
|
||||||
|
cp $ROOT/configs/server.template.yaml $DIST/configs/
|
||||||
|
|
||||||
|
EDGE_API_ZIP_FILE=$ROOT"/../../EdgeAPI/dist/edge-api-${OS}-${ARCH}-v${APINodeVersion}.zip"
|
||||||
|
cp $EDGE_API_ZIP_FILE $DIST/
|
||||||
|
cd $DIST/
|
||||||
|
unzip -q $(basename $EDGE_API_ZIP_FILE)
|
||||||
|
rm -f $(basename $EDGE_API_ZIP_FILE)
|
||||||
|
cd -
|
||||||
|
|
||||||
|
# build
|
||||||
|
echo "building "${NAME}" ..."
|
||||||
|
env GOOS=$OS GOARCH=$GOARCH go build -ldflags="-s -w" -tags demo -o $DIST/bin/${NAME} $ROOT/../cmd/edge-admin/main.go
|
||||||
|
|
||||||
|
# zip
|
||||||
|
echo "zip files ..."
|
||||||
|
cd "${DIST}/../" || exit
|
||||||
|
if [ -f "${ZIP}" ]; then
|
||||||
|
rm -f "${ZIP}"
|
||||||
|
fi
|
||||||
|
zip -r -X -q "${ZIP}" ${NAME}/
|
||||||
|
rm -rf ${NAME}
|
||||||
|
cd - || exit
|
||||||
|
|
||||||
|
echo "[done]"
|
||||||
|
}
|
||||||
|
|
||||||
|
function lookup-version() {
|
||||||
|
FILE=$1
|
||||||
|
VERSION_DATA=$(cat $FILE)
|
||||||
|
re="Version[ ]+=[ ]+\"([0-9.]+)\""
|
||||||
|
if [[ $VERSION_DATA =~ $re ]]; then
|
||||||
|
VERSION=${BASH_REMATCH[1]}
|
||||||
|
echo $VERSION
|
||||||
|
else
|
||||||
|
echo "could not match version"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
build $1 $2
|
||||||
7
internal/const/const_demo.go
Normal file
7
internal/const/const_demo.go
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
// +build demo
|
||||||
|
|
||||||
|
package teaconst
|
||||||
|
|
||||||
|
const (
|
||||||
|
IsDemo = true
|
||||||
|
)
|
||||||
7
internal/const/const_normal.go
Normal file
7
internal/const/const_normal.go
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
// +build !demo
|
||||||
|
|
||||||
|
package teaconst
|
||||||
|
|
||||||
|
const (
|
||||||
|
IsDemo = false
|
||||||
|
)
|
||||||
@@ -46,6 +46,12 @@ func (this *IndexAction) RunGet(params struct{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
nodeMap := maps.Map{}
|
nodeMap := maps.Map{}
|
||||||
|
if message.Node != nil {
|
||||||
|
nodeMap = maps.Map{
|
||||||
|
"id": message.Node.Id,
|
||||||
|
"name": message.Node.Name,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
messages = append(messages, maps.Map{
|
messages = append(messages, maps.Map{
|
||||||
"id": message.Id,
|
"id": message.Id,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package servers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||||
@@ -109,6 +110,11 @@ func (this *CreateAction) RunPost(params struct {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case serverconfigs.ServerTypeTCPProxy:
|
case serverconfigs.ServerTypeTCPProxy:
|
||||||
|
// 在DEMO模式下不能创建
|
||||||
|
if teaconst.IsDemo {
|
||||||
|
this.Fail("DEMO模式下不能创建TCP反向代理")
|
||||||
|
}
|
||||||
|
|
||||||
listen := []*serverconfigs.NetworkAddressConfig{}
|
listen := []*serverconfigs.NetworkAddressConfig{}
|
||||||
err := json.Unmarshal([]byte(params.Addresses), &listen)
|
err := json.Unmarshal([]byte(params.Addresses), &listen)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -21,6 +21,10 @@ Vue.component("message-row", {
|
|||||||
<span> | </span>
|
<span> | </span>
|
||||||
<a :href="'/clusters/cluster?clusterId=' + message.cluster.id">集群:{{message.cluster.name}}</a>
|
<a :href="'/clusters/cluster?clusterId=' + message.cluster.id">集群:{{message.cluster.name}}</a>
|
||||||
</span>
|
</span>
|
||||||
|
<span v-if="message.node != null && message.node.id != null">
|
||||||
|
<span> | </span>
|
||||||
|
<a :href="'/clusters/cluster/node?clusterId=' + message.cluster.id + '&nodeId=' + message.node.id">节点:{{message.node.name}}</a>
|
||||||
|
</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr :class="{error: message.level == 'error'}">
|
<tr :class="{error: message.level == 'error'}">
|
||||||
|
|||||||
Reference in New Issue
Block a user