MCPcopy
hub / github.com/grafana/dskit / Loop

Method Loop

signals/signals.go:49–73  ·  view source on GitHub ↗

Loop handles signals.

()

Source from the content-addressed store, hash-verified

47
48// Loop handles signals.
49func (h *Handler) Loop() {
50 sigs := make(chan os.Signal, 1)
51 signal.Notify(sigs, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGTERM)
52 defer signal.Stop(sigs)
53 buf := make([]byte, 1<<20)
54 for {
55 select {
56 case <-h.quit:
57 level.Info(h.log).Log("msg", "=== Handler.Stop()'d ===")
58 return
59 case sig := <-sigs:
60 switch sig {
61 case syscall.SIGINT, syscall.SIGTERM:
62 level.Info(h.log).Log("msg", "=== received SIGINT/SIGTERM ===\n*** exiting")
63 for _, subsystem := range h.receivers {
64 _ = subsystem.Stop()
65 }
66 return
67 case syscall.SIGQUIT:
68 stacklen := runtime.Stack(buf, true)
69 level.Info(h.log).Log("msg", dskit_log.LazySprintf("=== received SIGQUIT ===\n*** goroutine dump...\n%s\n*** end", buf[:stacklen]))
70 }
71 }
72 }
73}
74
75// SignalHandlerLoop blocks until it receives a SIGINT, SIGTERM or SIGQUIT.
76// For SIGINT and SIGTERM, it exits; for SIGQUIT is print a goroutine stack

Callers

nothing calls this directly

Calls 2

StopMethod · 0.65
LogMethod · 0.45

Tested by

no test coverage detected