mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-05 01:20:25 +08:00
优化启动速度
This commit is contained in:
@@ -2,16 +2,7 @@ package setup
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
_ "embed"
|
_ "embed"
|
||||||
"encoding/json"
|
|
||||||
"github.com/iwind/TeaGo/logs"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:embed sql.json
|
//go:embed sql.json
|
||||||
var sqlData []byte
|
var sqlData []byte
|
||||||
|
|
||||||
func init() {
|
|
||||||
err := json.Unmarshal(sqlData, LatestSQLResult)
|
|
||||||
if err != nil {
|
|
||||||
logs.Println("[ERROR]load sql failed: " + err.Error())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -18,8 +18,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var LatestSQLResult = &SQLDumpResult{}
|
|
||||||
|
|
||||||
// SQLExecutor 安装或升级SQL执行器
|
// SQLExecutor 安装或升级SQL执行器
|
||||||
type SQLExecutor struct {
|
type SQLExecutor struct {
|
||||||
dbConfig *dbs.DBConfig
|
dbConfig *dbs.DBConfig
|
||||||
@@ -65,7 +63,14 @@ func (this *SQLExecutor) Run(showLog bool) error {
|
|||||||
if this.logWriter != nil {
|
if this.logWriter != nil {
|
||||||
showLog = true
|
showLog = true
|
||||||
}
|
}
|
||||||
_, err = sqlDump.Apply(db, LatestSQLResult, showLog)
|
|
||||||
|
var sqlResult = &SQLDumpResult{}
|
||||||
|
err = json.Unmarshal(sqlData, sqlResult)
|
||||||
|
if err != nil {
|
||||||
|
return errors.New("decode sql data failed: " + err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = sqlDump.Apply(db, sqlResult, showLog)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user