Skip to content

Commit

Permalink
s/dh/sh
Browse files Browse the repository at this point in the history
  • Loading branch information
jesusvazquez committed Oct 2, 2023
1 parent ed4872f commit cda305e
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions pkg/internalserver/signal_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,37 +26,37 @@ type serverSignalHandler struct {
logger log.Logger
}

func (dh *serverSignalHandler) Loop() {
dh.ready.Store(true)
func (sh *serverSignalHandler) Loop() {
sh.ready.Store(true)

sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
defer signal.Stop(sigs)

for {
select {
case <-dh.quit:
case <-sh.quit:
return

case <-sigs:
level.Info(dh.logger).Log("msg", "=== received SIGINT/SIGTERM ===", "sleep", dh.shutdownDelay)
level.Info(sh.logger).Log("msg", "=== received SIGINT/SIGTERM ===", "sleep", sh.shutdownDelay)

// Not ready anymore.
dh.ready.Store(false)
if dh.shutdownDelay > 0 {
time.Sleep(dh.shutdownDelay)
sh.ready.Store(false)
if sh.shutdownDelay > 0 {
time.Sleep(sh.shutdownDelay)
}

level.Info(dh.logger).Log("msg", "shutting down")
level.Info(sh.logger).Log("msg", "shutting down")
return
}
}
}

func (dh *serverSignalHandler) Stop() {
close(dh.quit)
func (sh *serverSignalHandler) Stop() {
close(sh.quit)
}

func (dh *serverSignalHandler) Ready() bool {
return dh.ready.Load()
func (sh *serverSignalHandler) Ready() bool {
return sh.ready.Load()
}

0 comments on commit cda305e

Please sign in to comment.