func (self *RenderSelector) updateServiceStatus() { for _, render := range self.renders { if render.Status == Online { servicestatus.SetOK() return } } servicestatus.SetFAIL() }
func main() { cfg := Config{ Render: RenderConfig{ Threads: 1, Addr: ":8090", DebugAddr: ":9090", HotCacheDelay: "0s", }, CommonConfig: app.CommonConfig{ MetaSize: 8, TileSize: 256, }, } if cfg.Render.PerfLog != "" { perflog.SetupPerflog(cfg.Render.PerfLog) } app.App.Configure("Render", &cfg) τ0 := time.Now() cpI, err := plugins.DefaultPluginStore.Create(cfg.CachePlugin.Plugin, cfg.CachePlugin.PluginConfig) if err != nil { log.Fatal(err) } cp, ok := cpI.(gopnik.CachePluginInterface) if !ok { log.Fatal("Invalid cache plugin type") } removeDelay, err := time.ParseDuration(cfg.Render.HotCacheDelay) if err != nil { log.Fatalf("Invalid HotCacheDelay: %v", cfg.Render.HotCacheDelay) } ts, err := tileserver.NewTileServer(cfg.RenderPoolsConfig, cp, removeDelay) if err != nil { log.Fatalf("Failed to create tile server: %v", err) } δ := time.Since(τ0) log.Info("Done in %v seconds", δ.Seconds()) // USR1, SIGHUP for style reload go sigHandler(syscall.SIGUSR1, ts.ReloadStyle, "ReloadStyle error") go sigHandler(syscall.SIGHUP, ts.ReloadStyle, "ReloadStyle error") servicestatus.SetOK() // Service is Ok if renders starts log.Info("Starting on %s...", cfg.Render.Addr) log.Fatal(tileserver.RunServer(cfg.Render.Addr, ts)) }