From 9d610681d0fd8deb4bc73ea97787dd6b9a69b9f6 Mon Sep 17 00:00:00 2001 From: BuckarooBanzay Date: Tue, 14 Apr 2020 13:43:07 +0200 Subject: [PATCH] add incremental rendering pause config --- app/config.go | 70 +++++++++++++++++----------------- doc/config.md | 4 ++ tilerendererjob/incremental.go | 6 ++- 3 files changed, 45 insertions(+), 35 deletions(-) diff --git a/app/config.go b/app/config.go index 0e6da94..2a7fadb 100644 --- a/app/config.go +++ b/app/config.go @@ -10,23 +10,24 @@ import ( ) type Config struct { - ConfigVersion int `json:"configversion"` - Port int `json:"port"` - EnablePrometheus bool `json:"enableprometheus"` - EnableRendering bool `json:"enablerendering"` - EnableSearch bool `json:"enablesearch"` - EnableInitialRendering bool `json:"enableinitialrendering"` - EnableTransparency bool `json:"enabletransparency"` - EnableMediaRepository bool `json:"enablemediarepository"` - Webdev bool `json:"webdev"` - WebApi *WebApiConfig `json:"webapi"` - Layers []*layer.Layer `json:"layers"` - RenderingFetchLimit int `json:"renderingfetchlimit"` - RenderingJobs int `json:"renderingjobs"` - RenderingQueue int `json:"renderingqueue"` - MapObjects *MapObjectConfig `json:"mapobjects"` - MapBlockAccessorCfg *MapBlockAccessorConfig `json:"mapblockaccessor"` - DefaultOverlays []string `json:"defaultoverlays"` + ConfigVersion int `json:"configversion"` + Port int `json:"port"` + EnablePrometheus bool `json:"enableprometheus"` + EnableRendering bool `json:"enablerendering"` + EnableSearch bool `json:"enablesearch"` + EnableInitialRendering bool `json:"enableinitialrendering"` + EnableTransparency bool `json:"enabletransparency"` + EnableMediaRepository bool `json:"enablemediarepository"` + Webdev bool `json:"webdev"` + WebApi *WebApiConfig `json:"webapi"` + Layers []*layer.Layer `json:"layers"` + RenderingFetchLimit int `json:"renderingfetchlimit"` + RenderingJobs int `json:"renderingjobs"` + RenderingQueue int `json:"renderingqueue"` + IncrementalRenderingTimer string `json:"incrementalrenderingtimer"` + MapObjects *MapObjectConfig `json:"mapobjects"` + MapBlockAccessorCfg *MapBlockAccessorConfig `json:"mapblockaccessor"` + DefaultOverlays []string `json:"defaultoverlays"` } type MapBlockAccessorConfig struct { @@ -168,23 +169,24 @@ func ParseConfig(filename string) (*Config, error) { } cfg := Config{ - ConfigVersion: 1, - Port: 8080, - EnableRendering: true, - EnablePrometheus: true, - EnableSearch: true, - EnableInitialRendering: true, - EnableTransparency: false, - EnableMediaRepository: false, - Webdev: false, - WebApi: &webapi, - Layers: layers, - RenderingFetchLimit: 10000, - RenderingJobs: runtime.NumCPU(), - RenderingQueue: 100, - MapObjects: &mapobjs, - MapBlockAccessorCfg: &mapblockaccessor, - DefaultOverlays: defaultoverlays, + ConfigVersion: 1, + Port: 8080, + EnableRendering: true, + EnablePrometheus: true, + EnableSearch: true, + EnableInitialRendering: true, + EnableTransparency: false, + EnableMediaRepository: false, + Webdev: false, + WebApi: &webapi, + Layers: layers, + RenderingFetchLimit: 10000, + RenderingJobs: runtime.NumCPU(), + RenderingQueue: 100, + IncrementalRenderingTimer: "5s", + MapObjects: &mapobjs, + MapBlockAccessorCfg: &mapblockaccessor, + DefaultOverlays: defaultoverlays, } info, err := os.Stat(filename) diff --git a/doc/config.md b/doc/config.md index becc4a5..9d97a9f 100644 --- a/doc/config.md +++ b/doc/config.md @@ -43,6 +43,7 @@ The mapserver will generate a fresh `mapserver.json` if there is none at startup "renderingfetchlimit": 1000, "renderingjobs": 2, "renderingqueue": 100, + "incrementalrenderingtimer": "5s", "mapobjects": { "bones": true, "protector": true, @@ -110,6 +111,9 @@ Number of mapblocks to collect at once while rendering: For a small system (Raspberry PI) a setting of 1000 is ok. Faster system can use the default (10'000) +#### incrementalrenderingtimer +Duration to let pass between incremental rendering executions. + #### enableprometheus Enables the [Prometheus](./prometheus.md) metrics endpoint diff --git a/tilerendererjob/incremental.go b/tilerendererjob/incremental.go index 0b2c41d..6344cd3 100644 --- a/tilerendererjob/incremental.go +++ b/tilerendererjob/incremental.go @@ -31,7 +31,11 @@ func incrementalRender(ctx *app.App) { } if len(result.List) == 0 && !result.HasMore { - time.Sleep(5 * time.Second) + renderingDuration, err := time.ParseDuration(ctx.Config.IncrementalRenderingTimer) + if err != nil { + panic(err) + } + time.Sleep(renderingDuration) continue }