Skip to content

Commit

Permalink
A bit primitive, but this'll work for now
Browse files Browse the repository at this point in the history
  • Loading branch information
Dynom committed Jul 9, 2018
1 parent 2467086 commit caafab7
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ func main() {
panic(err)
}

err = overrideConfigFromEnv(&config)
if err != nil {
panic(err)
}

logger := logrus.New()
logger.Formatter = &logrus.JSONFormatter{}
logger.Out = os.Stdout
Expand Down Expand Up @@ -113,3 +118,27 @@ func buildConfig(fileName string) (Config, error) {

return c, nil
}

func overrideConfigFromEnv(c *Config) error {
if v, exists := os.LookupEnv("LISTEN_URL"); exists {
c.Server.ListenOn = v
}

if v, exists := os.LookupEnv("LOG_LEVEL"); exists {
c.Server.Log.Level = v
}

if v, exists := os.LookupEnv("PROFILER_PREFIX"); exists {
c.Server.Profiler.Prefix = v
}

if v, exists := os.LookupEnv("PROFILER_ENABLE"); exists {
if v == "true" {
c.Server.Profiler.Enable = true
} else {
c.Server.Profiler.Enable = false
}
}

return nil
}

0 comments on commit caafab7

Please sign in to comment.