1
0
forked from MTSR/mapserver
mapserver/tileupdate/job.go
NatureFreshMilk a508ea0f7b readme / todo
2019-01-18 15:25:45 +01:00

40 lines
631 B
Go

package tileupdate
import (
"github.com/sirupsen/logrus"
"mapserver/app"
"time"
)
func Job(ctx *app.App) {
//TODO remember last time run
t := time.Now().Unix()
fields := logrus.Fields{
"time": t,
}
logrus.WithFields(fields).Info("Starting incremental update")
for true {
mblist, err := ctx.BlockAccessor.FindLatestMapBlocks(t, 1000)
if err != nil {
panic(err)
}
for _, mb := range mblist {
if mb.Mtime > t {
t = mb.Mtime + 1
}
}
fields = logrus.Fields{
"count": len(mblist),
"time": t,
}
logrus.WithFields(fields).Info("incremental update")
time.Sleep(5 * time.Second)
}
}