chore: auto update geo

This commit is contained in:
Larvan2
2024-05-19 17:30:39 +08:00
committed by wwqgtxx
parent e749c7e492
commit 4243a74284
3 changed files with 42 additions and 63 deletions

26
main.go
View File

@@ -113,23 +113,19 @@ func main() {
}
if C.GeoAutoUpdate {
updateNotification := make(chan struct{})
go updater.RegisterGeoUpdater(updateNotification)
go func() {
for range updateNotification {
cfg, err := executor.ParseWithPath(C.Path.Config())
if err != nil {
log.Errorln("[GEO] update GEO databases failed: %v", err)
return
}
log.Warnln("[GEO] update GEO databases success, applying config")
executor.ApplyConfig(cfg, false)
updater.RegisterGeoUpdater(func() {
cfg, err := executor.ParseWithPath(C.Path.Config())
if err != nil {
log.Errorln("[GEO] update GEO databases failed: %v", err)
return
}
}()
log.Warnln("[GEO] update GEO databases success, applying config")
executor.ApplyConfig(cfg, false)
})
}
defer executor.Shutdown()
termSign := make(chan os.Signal, 1)