Skip to content

Commit

Permalink
SIGHUP is only useful when config was loaded from a file (#1030)
Browse files Browse the repository at this point in the history
Have (*config.C).CatchHUP() return early when there is no file
path available from which to reload.
This will allow wrapping service to manage their own signal
trapping (which is particularly important if they've used
config from a string.
  • Loading branch information
forfuncsake authored Dec 6, 2023
1 parent fb55f5b commit 0209402
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ func (c *C) HasChanged(k string) bool {
// CatchHUP will listen for the HUP signal in a go routine and reload all configs found in the
// original path provided to Load. The old settings are shallow copied for change detection after the reload.
func (c *C) CatchHUP(ctx context.Context) {
if c.path == "" {
return
}

ch := make(chan os.Signal, 1)
signal.Notify(ch, syscall.SIGHUP)

Expand Down

0 comments on commit 0209402

Please sign in to comment.