From 421fc0e22dbc531a6d62b5e8fc1b3b935c34fe8c Mon Sep 17 00:00:00 2001 From: John Shahid Date: Thu, 29 May 2014 18:56:51 -0400 Subject: [PATCH] simplify the code since we don't need the quit channel --- src/daemon/influxd.go | 4 ++-- src/server/server.go | 23 +++++++---------------- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/src/daemon/influxd.go b/src/daemon/influxd.go index 980c09e3e4..d924c728e9 100644 --- a/src/daemon/influxd.go +++ b/src/daemon/influxd.go @@ -66,7 +66,7 @@ func main() { runtime.GOMAXPROCS(runtime.NumCPU()) flag.Parse() - version := fmt.Sprintf("InfluxDB v%s (git: %s) (leveldb: %d.%d)", version, gitSha, levigo.GetLevelDBMajorVersion(), levigo.GetLevelDBMinorVersion()) + v := fmt.Sprintf("InfluxDB v%s (git: %s) (leveldb: %d.%d)", version, gitSha, levigo.GetLevelDBMajorVersion(), levigo.GetLevelDBMinorVersion()) if wantsVersion != nil && *wantsVersion { fmt.Println(version) return @@ -86,7 +86,7 @@ func main() { config.ProtobufPort = *protobufPort } - config.Version = version + config.Version = v config.InfluxDBVersion = version setupLogging(config.LogLevel, config.LogFile) diff --git a/src/server/server.go b/src/server/server.go index c782aac1da..744e54e21d 100644 --- a/src/server/server.go +++ b/src/server/server.go @@ -160,7 +160,7 @@ func (self *Server) ListenAndServe() error { log.Debug("ReportingDisabled: %s", self.Config.ReportingDisabled) if !self.Config.ReportingDisabled { - self.startReportingLoop() + go self.startReportingLoop() } // start processing continuous queries @@ -173,25 +173,16 @@ func (self *Server) ListenAndServe() error { } func (self *Server) startReportingLoop() chan struct{} { - quit := make(chan struct{}) - log.Debug("Starting Reporting Loop") self.reportStats() ticker := time.NewTicker(24 * time.Hour) - go func() { - for { - select { - case <-ticker.C: - self.reportStats() - case <-quit: - ticker.Stop() - return - } + for { + select { + case <-ticker.C: + self.reportStats() } - }() - - return quit + } } func (self *Server) reportStats() { @@ -213,7 +204,7 @@ func (self *Server) reportStats() { }, } - log.Info("Reporting stats: %s", series) + log.Info("Reporting stats: %#v", series) client.WriteSeries([]*influxdb.Series{series}) } }