diff --git a/api/main.go b/api/main.go index bc31f1a..0d60955 100644 --- a/api/main.go +++ b/api/main.go @@ -59,6 +59,8 @@ func main() { // init geoip utils.InitGeoIP() + // start geoip refresh loop + go routines.RefreshGeoIPDatabase() // starts remote info loop go routines.RefreshRemoteInfoLoop() diff --git a/api/routines/routines.go b/api/routines/routines.go index ab75777..386207d 100644 --- a/api/routines/routines.go +++ b/api/routines/routines.go @@ -10,6 +10,7 @@ package routines import ( + "github.com/NethServer/nethsecurity-controller/api/utils" "time" "github.com/NethServer/nethsecurity-controller/api/logs" @@ -33,3 +34,13 @@ func RefreshRemoteInfoLoop() { } } } + +func RefreshGeoIPDatabase() { + ticker := time.NewTicker(24 * time.Hour) + for range ticker.C { + err := utils.InitGeoIP() + if err != nil { + logs.Logs.Println("[ERR][ROUTINE] loop for geoip database failed: " + err.Error()) + } + } +}