mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-23 20:37:12 +01: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
@ -16,8 +16,8 @@ import (
|
|||||||
// since this signal is frequently used for config reloading.
|
// since this signal is frequently used for config reloading.
|
||||||
func WaitForSigterm() os.Signal {
|
func WaitForSigterm() os.Signal {
|
||||||
ch := make(chan os.Signal, 1)
|
ch := make(chan os.Signal, 1)
|
||||||
|
signal.Notify(ch, os.Interrupt, syscall.SIGTERM, syscall.SIGHUP)
|
||||||
for {
|
for {
|
||||||
signal.Notify(ch, os.Interrupt, syscall.SIGTERM, syscall.SIGHUP)
|
|
||||||
sig := <-ch
|
sig := <-ch
|
||||||
if sig == syscall.SIGHUP {
|
if sig == syscall.SIGHUP {
|
||||||
// Prevent from the program stop on SIGHUP
|
// Prevent from the program stop on SIGHUP
|
||||||
@ -33,3 +33,10 @@ func SelfSIGHUP() {
|
|||||||
logger.Panicf("FATAL: cannot send SIGHUP to itself: %s", err)
|
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"
|
"bytes"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
"os/signal"
|
|
||||||
"sync"
|
"sync"
|
||||||
"syscall"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/logger"
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/logger"
|
||||||
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/procutil"
|
||||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/prompbmarshal"
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/prompbmarshal"
|
||||||
"github.com/VictoriaMetrics/metrics"
|
"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("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() })
|
scs.add("gce_sd_configs", *gceSDCheckInterval, func(cfg *Config, swsPrev []ScrapeWork) []ScrapeWork { return cfg.getGCESDScrapeWork() })
|
||||||
|
|
||||||
sighupCh := make(chan os.Signal, 1)
|
sighupCh := procutil.NewSighupChan()
|
||||||
signal.Notify(sighupCh, syscall.SIGHUP)
|
|
||||||
|
|
||||||
var tickerCh <-chan time.Time
|
var tickerCh <-chan time.Time
|
||||||
if *configCheckInterval > 0 {
|
if *configCheckInterval > 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user