mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/procutil: add NewSighupChan function, which returns a channel, which is triggered on every SIGHUP
This commit is contained in:
parent
1aea001532
commit
7b5ef63384
2 changed files with 10 additions and 6 deletions
|
@ -16,8 +16,8 @@ import (
|
|||
// since this signal is frequently used for config reloading.
|
||||
func WaitForSigterm() os.Signal {
|
||||
ch := make(chan os.Signal, 1)
|
||||
signal.Notify(ch, os.Interrupt, syscall.SIGTERM, syscall.SIGHUP)
|
||||
for {
|
||||
signal.Notify(ch, os.Interrupt, syscall.SIGTERM, syscall.SIGHUP)
|
||||
sig := <-ch
|
||||
if sig == syscall.SIGHUP {
|
||||
// Prevent from the program stop on SIGHUP
|
||||
|
@ -33,3 +33,10 @@ func SelfSIGHUP() {
|
|||
logger.Panicf("FATAL: cannot send SIGHUP to itself: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
// NewSighupChan returns a channel, which is triggered on every SIGHUP.
|
||||
func NewSighupChan() <-chan os.Signal {
|
||||
ch := make(chan os.Signal, 1)
|
||||
signal.Notify(ch, syscall.SIGHUP)
|
||||
return ch
|
||||
}
|
||||
|
|
|
@ -4,13 +4,11 @@ import (
|
|||
"bytes"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/logger"
|
||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/procutil"
|
||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/prompbmarshal"
|
||||
"github.com/VictoriaMetrics/metrics"
|
||||
)
|
||||
|
@ -79,8 +77,7 @@ func runScraper(configFile string, pushData func(wr *prompbmarshal.WriteRequest)
|
|||
scs.add("ec2_sd_configs", *ec2SDCheckInterval, func(cfg *Config, swsPrev []ScrapeWork) []ScrapeWork { return cfg.getEC2SDScrapeWork() })
|
||||
scs.add("gce_sd_configs", *gceSDCheckInterval, func(cfg *Config, swsPrev []ScrapeWork) []ScrapeWork { return cfg.getGCESDScrapeWork() })
|
||||
|
||||
sighupCh := make(chan os.Signal, 1)
|
||||
signal.Notify(sighupCh, syscall.SIGHUP)
|
||||
sighupCh := procutil.NewSighupChan()
|
||||
|
||||
var tickerCh <-chan time.Time
|
||||
if *configCheckInterval > 0 {
|
||||
|
|
Loading…
Reference in a new issue