Skip to content

Commit b425cfa

Browse files
authored
chore: use a reloadable config for deciding whether to shudown on non-reloadable config change (#6036)
# Description Using an environment variable proved to be suboptimal ## Security - [x] The code changed/added as part of this pull request won't create any security issues with how the software is being used.
1 parent 456723f commit b425cfa

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

main.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,15 @@ func main() {
3737
debug.SetMemoryLimit(memoryLimit)
3838
}
3939

40-
if c.GetBool("SHUTDOWN_ON_NON_RELOADABLE_CONFIG_CHANGE", false) {
41-
c.OnNonReloadableConfigChange(func(key string) {
40+
shutdownOnNonReloadableConfigChange := c.GetReloadableBoolVar(false, "shutdownOnNonReloadableConfigChange")
41+
c.OnNonReloadableConfigChange(func(key string) {
42+
if shutdownOnNonReloadableConfigChange.Load() {
4243
log.Infon("Config change detected, shutting down server...", logger.NewStringField("key", key))
4344
cancel()
44-
})
45-
}
45+
} else {
46+
log.Infon("Config change detected, but server will not shut down", logger.NewStringField("key", key))
47+
}
48+
})
4649

4750
r := runner.New(runner.ReleaseInfo{
4851
Version: version,

0 commit comments

Comments
 (0)