mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-08 19:40:24 +08:00
优化单例应用安装程序
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
package instances
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
@@ -77,6 +78,15 @@ func (this *Instance) SetupDB() error {
|
||||
_ = db.Close()
|
||||
}()
|
||||
|
||||
// 等待连接成功
|
||||
for i := 0; i < 30; i++ {
|
||||
err := db.Raw().PingContext(context.Background())
|
||||
if err == nil {
|
||||
break
|
||||
}
|
||||
time.Sleep(1 * time.Second)
|
||||
}
|
||||
|
||||
_, err := db.Exec("USE `" + this.options.DB.Name + "`")
|
||||
if err != nil {
|
||||
if models.CheckSQLErrCode(err, 1049) {
|
||||
|
||||
Reference in New Issue
Block a user