mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-15 00:13:30 +01:00
app/vminsert: add /-/reload
handler in the same way as for vmagent
This commit is contained in:
parent
a970705d8e
commit
b21b73115a
@ -5,7 +5,6 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/VictoriaMetrics/VictoriaMetrics/app/vmagent/csvimport"
|
||||
@ -160,11 +159,7 @@ func requestHandler(w http.ResponseWriter, r *http.Request) bool {
|
||||
return true
|
||||
case "/-/reload":
|
||||
promscrapeConfigReloadRequests.Inc()
|
||||
if err := syscall.Kill(syscall.Getpid(), syscall.SIGHUP); err != nil {
|
||||
promscrapeConfigReloadErrors.Inc()
|
||||
httpserver.Errorf(w, "Fail to reload config file, %s", err)
|
||||
return true
|
||||
}
|
||||
procutil.SelfSIGHUP()
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
return true
|
||||
}
|
||||
@ -189,5 +184,4 @@ var (
|
||||
promscrapeTargetsRequests = metrics.NewCounter(`vmagent_http_requests_total{path="/targets"}`)
|
||||
|
||||
promscrapeConfigReloadRequests = metrics.NewCounter(`vmagent_http_requests_total{path="/-/reload"}`)
|
||||
promscrapeConfigReloadErrors = metrics.NewCounter(`vmagent_http_request_errors_total{path="/-/reload"}`)
|
||||
)
|
||||
|
@ -4,6 +4,8 @@ import (
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/logger"
|
||||
)
|
||||
|
||||
// WaitForSigterm waits for either SIGTERM or SIGINT
|
||||
@ -24,3 +26,10 @@ func WaitForSigterm() os.Signal {
|
||||
return sig
|
||||
}
|
||||
}
|
||||
|
||||
// SelfSIGHUP sends SIGHUP signal to the current process.
|
||||
func SelfSIGHUP() {
|
||||
if err := syscall.Kill(syscall.Getpid(), syscall.SIGHUP); err != nil {
|
||||
logger.Panicf("FATAL: cannot send SIGHUP to itself: %s", err)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user