-
Notifications
You must be signed in to change notification settings - Fork 60
/
signal.go
53 lines (48 loc) · 1.24 KB
/
signal.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//go:build !windows
// +build !windows
package main
import (
"fmt"
"os"
"os/signal"
"syscall"
"github.com/go-kit/log/level"
)
func reloadSignal() {
// Signal handling
hup := make(chan os.Signal, 1)
signal.Notify(hup, syscall.SIGHUP)
susr := make(chan os.Signal, 1)
signal.Notify(susr, syscall.SIGUSR1)
go func() {
for {
select {
case <-hup:
level.Debug(logger).Log("msg", "Signal: HUP")
level.Info(logger).Log("msg", "ReLoading config")
if err := sc.ReloadConfig(logger, *configFile); err != nil {
level.Error(logger).Log("msg", "Reloading config skipped", "err", err)
continue
} else {
monitorPING.DelTargets()
_ = monitorPING.CheckActiveTargets()
monitorPING.AddTargets()
monitorMTR.DelTargets()
_ = monitorMTR.CheckActiveTargets()
monitorMTR.AddTargets()
monitorTCP.DelTargets()
_ = monitorTCP.CheckActiveTargets()
monitorTCP.AddTargets()
monitorHTTPGet.DelTargets()
monitorHTTPGet.AddTargets()
}
case <-susr:
level.Debug(logger).Log("msg", "Signal: USR1")
fmt.Printf("PING: %+v\n", monitorPING)
fmt.Printf("MTR: %+v\n", monitorMTR)
fmt.Printf("TCP: %+v\n", monitorTCP)
fmt.Printf("HTTPGet: %+v\n", monitorHTTPGet)
}
}
}()
}