flush tile list at most every 30 seconds
parent
5b132abfb1
commit
4ac7509e7d
28
diff/run.go
28
diff/run.go
|
@ -59,21 +59,28 @@ func Run() {
|
||||||
sigc := make(chan os.Signal, 1)
|
sigc := make(chan os.Signal, 1)
|
||||||
signal.Notify(sigc, syscall.SIGTERM, syscall.SIGINT, syscall.SIGHUP)
|
signal.Notify(sigc, syscall.SIGTERM, syscall.SIGINT, syscall.SIGHUP)
|
||||||
|
|
||||||
|
var tilelist *expire.TileList
|
||||||
|
var lastTlFlush = time.Now()
|
||||||
|
var tileExpireor expire.Expireor
|
||||||
|
if config.BaseOptions.ExpireTilesDir != "" {
|
||||||
|
tilelist = expire.NewTileList(config.BaseOptions.ExpireTilesZoom, config.BaseOptions.ExpireTilesDir)
|
||||||
|
tileExpireor = tilelist
|
||||||
|
}
|
||||||
|
|
||||||
shutdown := func() {
|
shutdown := func() {
|
||||||
logger.Print("Exiting. (SIGTERM/SIGINT/SIGHUB)")
|
logger.Print("Exiting. (SIGTERM/SIGINT/SIGHUB)")
|
||||||
logging.Shutdown()
|
logging.Shutdown()
|
||||||
osmCache.Close()
|
osmCache.Close()
|
||||||
diffCache.Close()
|
diffCache.Close()
|
||||||
|
if tilelist != nil {
|
||||||
|
err := tilelist.Flush()
|
||||||
|
if err != nil {
|
||||||
|
logger.Print("error writing tile expire list", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
var tiles *expire.TileList
|
|
||||||
var tileExpireor expire.Expireor
|
|
||||||
if config.BaseOptions.ExpireTilesDir != "" {
|
|
||||||
tiles = expire.NewTileList(config.BaseOptions.ExpireTilesZoom, config.BaseOptions.ExpireTilesDir)
|
|
||||||
tileExpireor = tiles
|
|
||||||
}
|
|
||||||
|
|
||||||
exp := newExpBackoff(2*time.Second, 5*time.Minute)
|
exp := newExpBackoff(2*time.Second, 5*time.Minute)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
@ -91,8 +98,11 @@ func Run() {
|
||||||
osmCache.Coords.Flush()
|
osmCache.Coords.Flush()
|
||||||
diffCache.Flush()
|
diffCache.Flush()
|
||||||
|
|
||||||
if err == nil && tiles != nil {
|
if err == nil && tilelist != nil && time.Since(lastTlFlush) > time.Second*30 {
|
||||||
err := tiles.Flush()
|
// call at most once every 30 seconds to reduce files during the
|
||||||
|
// catch-up phase after the initial import
|
||||||
|
lastTlFlush = time.Now()
|
||||||
|
err := tilelist.Flush()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Print("error writing tile expire list", err)
|
logger.Print("error writing tile expire list", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue