可以使用EdgeRecover环境变量指示恢复数据库

This commit is contained in:
GoEdgeLab
2022-09-07 14:44:36 +08:00
parent 390d42c5d9
commit 4074648bf1
3 changed files with 27 additions and 7 deletions

View File

@@ -101,6 +101,14 @@ func (this *Task) Init() error {
db.SetMaxOpenConns(1)
this.db = dbs.NewDB(db)
// 恢复数据库
var recoverEnv, _ = os.LookupEnv("EdgeRecover")
if len(recoverEnv) > 0 {
for _, indexName := range []string{"serverId", "hash"} {
_, _ = db.Exec(`REINDEX "` + indexName + `"`)
}
}
if teaconst.EnableDBStat {
this.db.EnableStat(true)
}