func main() { if os.Getenv("GOMAXPROCS") == "" { runtime.GOMAXPROCS(runtime.NumCPU()) } store = nil defer func() { if err := recover(); err != nil { log.Printf("Caught panic in the main thread: %s", err) shutdown() } }() incus.NewConfig(configFilePath) initLogger() log.Printf("Incus built on %s", BUILD) InstallSignalHandlers() var stats incus.RuntimeStats if viper.GetBool("datadog_enabled") { stats, _ = incus.NewDatadogStats(viper.GetString("datadog_host")) } else { stats = &incus.DiscardStats{} } stats.LogStartup() store = incus.NewStore(stats) incus.CLIENT_BROAD = viper.GetBool("client_broadcasts") server := incus.NewServer(store, stats) go server.RecordStats(1 * time.Second) go server.LogConnectedClientsPeriodically(20 * time.Second) go server.ListenFromRedis() go server.ListenFromSockets() go server.ListenFromLongpoll() go server.MonitorLongpollKillswitch() go server.ListenForHTTPPings() go server.SendHeartbeatsPeriodically(20 * time.Second) go listenAndServeTLS() listenAndServe() }
func main() { if os.Getenv("GOMAXPROCS") == "" { runtime.GOMAXPROCS(runtime.NumCPU()) } store = nil defer func() { if err := recover(); err != nil { log.Printf("Caught panic in the main thread: %s", err) shutdown() } }() conf := incus.NewConfig() initLogger(conf) log.Printf("Incus built on %s", BUILD) InstallSignalHandlers() store = incus.NewStore(&conf) incus.CLIENT_BROAD = conf.GetBool("client_broadcasts") server := incus.NewServer(&conf, store) go server.RecordStats(1 * time.Second) go server.LogConnectedClientsPeriodically(20 * time.Second) go server.ListenFromRedis() go server.ListenFromSockets() go server.ListenFromLongpoll() go server.ListenForHTTPPings() go server.SendHeartbeatsPeriodically(20 * time.Second) go listenAndServeTLS(conf) listenAndServe(conf) }