优化单例应用安装程序

This commit is contained in:
刘祥超
2024-03-02 20:51:13 +08:00
parent e763095756
commit 97c76ef22f
2 changed files with 25 additions and 10 deletions

View File

@@ -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) {