安装时检查数据库版本

This commit is contained in:
GoEdgeLab
2020-11-24 08:38:19 +08:00
parent 5c68607583
commit e50ddb95f3
3 changed files with 21 additions and 1 deletions

View File

@@ -7,8 +7,8 @@ import (
var isConfigured bool var isConfigured bool
// 判断系统是否已经配置过 // 判断系统是否已经配置过
// TODO 检查节点版本和数据库版本是否一致,如果不一致则跳转到升级页面
func IsConfigured() bool { func IsConfigured() bool {
return false//TODO
if isConfigured { if isConfigured {
return true return true
} }

View File

@@ -3,6 +3,7 @@ package tasks
import ( import (
"github.com/TeaOSLab/EdgeAdmin/internal/events" "github.com/TeaOSLab/EdgeAdmin/internal/events"
"github.com/TeaOSLab/EdgeAdmin/internal/rpc" "github.com/TeaOSLab/EdgeAdmin/internal/rpc"
"github.com/TeaOSLab/EdgeAdmin/internal/setup"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/nodes/nodeutils" "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/nodes/nodeutils"
"github.com/TeaOSLab/EdgeCommon/pkg/messageconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/messageconfigs"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
@@ -37,6 +38,11 @@ func (this *SyncClusterTask) Start() {
} }
func (this *SyncClusterTask) loop() error { func (this *SyncClusterTask) loop() error {
// 如果还没有安装直接返回
if !setup.IsConfigured() {
return nil
}
rpcClient, err := rpc.SharedRPC() rpcClient, err := rpc.SharedRPC()
if err != nil { if err != nil {
return err return err

View File

@@ -6,6 +6,7 @@ import (
"github.com/iwind/TeaGo/actions" "github.com/iwind/TeaGo/actions"
"github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/dbs"
"github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/maps"
stringutil "github.com/iwind/TeaGo/utils/string"
"strings" "strings"
) )
@@ -65,6 +66,19 @@ func (this *ValidateDbAction) RunPost(params struct {
} }
} }
// 检查数据库版本
one, err := db.FindOne("SELECT VERSION() AS v")
if err != nil {
this.Fail("检查数据库版本时出错:" + err.Error())
}
if one == nil {
this.Fail("检查数据库版本时出错:无法获取数据库版本")
}
version := one.GetString("v")
if stringutil.VersionCompare(version, "5.7.8") < 0 {
this.Fail("数据库版本至少在v5.7.8以上你现在使用的是v" + version)
}
this.Data["db"] = maps.Map{ this.Data["db"] = maps.Map{
"host": params.Host, "host": params.Host,
"port": params.Port, "port": params.Port,