Skip to content

Commit

Permalink
Make refresh_delay configurable and skip it on boot (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
arekkas authored Nov 7, 2017
1 parent 6570b5d commit 4863a82
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions cmd/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ var allCmd = &cobra.Command{
bearerTokenSecret: viper.GetString("JWT_SHARED_SECRET"),
cors: parseCorsOptions(""),
address: fmt.Sprintf("%s:%s", viper.GetString("PROXY_HOST"), viper.GetString("PROXY_PORT")),
refreshDelay: viper.GetString("REFRESH_DELAY"),
}

mc := &managementConfig{
Expand Down
4 changes: 2 additions & 2 deletions cmd/helper_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ func refresh(c *proxyConfig, m *rule.CachedMatcher, fails int) {
duration = time.Second * 30
}

time.Sleep(duration)

if err := m.Refresh(); err != nil {
logger.WithError(err).WithField("retry", fails).Errorln("Unable to refresh rules.")
if fails > 15 {
Expand All @@ -28,6 +26,8 @@ func refresh(c *proxyConfig, m *rule.CachedMatcher, fails int) {
return
}

time.Sleep(duration)

refresh(c, m, 0)
}

Expand Down
1 change: 1 addition & 0 deletions cmd/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ var proxyCmd = &cobra.Command{
bearerTokenSecret: viper.GetString("JWT_SHARED_SECRET"),
cors: parseCorsOptions(""),
address: fmt.Sprintf("%s:%s", viper.GetString("PROXY_HOST"), viper.GetString("PROXY_PORT")),
refreshDelay: viper.GetString("REFRESH_DELAY"),
}

runProxy(config)
Expand Down
1 change: 1 addition & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func initConfig() {
viper.SetDefault("LOG_LEVEL", "info")
viper.SetDefault("PROXY_PORT", "4455")
viper.SetDefault("MANAGEMENT_PORT", "4456")
viper.SetDefault("REFRESH_DELAY", "5s")

// If a config file is found, read it in.
if err := viper.ReadInConfig(); err == nil {
Expand Down

0 comments on commit 4863a82

Please sign in to comment.