minor refactors
This commit is contained in:
1 parent
8caa58af26
commit
14b99fac2a
1 file changed
+4
-5
+4
-5
@@ -8,18 +8,17 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// A subsystem/server/... that can be stopped or queried about the status with a signal
|
// A subsystem/server/... that can be stopped or queried about the status with a signal
|
||||||
type SignalsReceiver interface {
|
type SignalReceiver interface {
|
||||||
Status() string
|
|
||||||
Stop() error
|
Stop() error
|
||||||
|
Status() string
|
||||||
}
|
}
|
||||||
|
|
||||||
func SignalHandlerLoop(ss ...SignalsReceiver) {
|
func SignalHandlerLoop(ss ...SignalReceiver) {
|
||||||
sigs := make(chan os.Signal, 1)
|
sigs := make(chan os.Signal, 1)
|
||||||
signal.Notify(sigs, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGUSR1)
|
signal.Notify(sigs, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGUSR1)
|
||||||
buf := make([]byte, 1<<20)
|
buf := make([]byte, 1<<20)
|
||||||
for {
|
for {
|
||||||
sig := <-sigs
|
switch <-sigs {
|
||||||
switch sig {
|
|
||||||
case syscall.SIGINT:
|
case syscall.SIGINT:
|
||||||
Info.Printf("=== received SIGINT ===\n*** exiting\n")
|
Info.Printf("=== received SIGINT ===\n*** exiting\n")
|
||||||
for _, subsystem := range ss {
|
for _, subsystem := range ss {
|
||||||
|
|||||||
Reference in new issue
Block a user