Skip to content

Commit

Permalink
Merge pull request #14 from mozilla-services/ajvb/prefer-statsd-env-var
Browse files Browse the repository at this point in the history
Prefer STATSD_HOST env var over config value; fixes #13
  • Loading branch information
ajvb authored Feb 19, 2019
2 parents 177f71d + dcb5e32 commit 7653bd6
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions iprepd.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package iprepd

import (
"fmt"
"io/ioutil"
"math/rand"
"os"
"time"

log "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -93,6 +95,15 @@ func loadCfg(confpath string) (ret serverCfg, err error) {
if err != nil {
return
}
// prefer STATSD_HOST env var over config file (#13)
statsdHost := os.Getenv("STATSD_HOST")
if statsdHost != "" {
statsdPort := os.Getenv("STATSD_PORT")
if statsdPort == "" {
statsdPort = "8125"
}
ret.Statsd.Addr = fmt.Sprintf("%s:%s", statsdHost, statsdPort)
}
return ret, ret.validate()
}

Expand Down

0 comments on commit 7653bd6

Please sign in to comment.