fix panic when there were no recent errors

This commit is contained in:
Alex Grintsvayg 2018-08-31 06:38:38 -04:00
parent 5d844fc3ea
commit 146adcf7fd
2 changed files with 8 additions and 5 deletions

View file

@ -102,8 +102,10 @@ func (s *stats) log() {
delete(s.errors, name)
}
s.mu.Unlock()
s.logger.Printf(
"Stats: %d blobs, %d streams, errors: %s",
blobs, streams, errStr[:len(errStr)-2], // trim last comma and space
)
if len(errStr) > 2 {
errStr = errStr[:len(errStr)-2] // trim last comma and space
}
s.logger.Printf("Stats: %d blobs, %d streams, errors: %s", blobs, streams, errStr)
}

View file

@ -15,8 +15,9 @@ import (
// TODO: this needs to be shut down cleanly
func Run(url, updateCmd string) {
t := time.NewTicker(1 * time.Minute)
for {
<-time.After(1 * time.Minute)
<-t.C
r, err := http.Head(url)
if err != nil {