Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make refresh_delay configurable and skip it on boot #18

Merged
merged 1 commit into from
Nov 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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