mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-15 08:23:34 +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"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/VictoriaMetrics/VictoriaMetrics/app/vmagent/csvimport"
|
"github.com/VictoriaMetrics/VictoriaMetrics/app/vmagent/csvimport"
|
||||||
@ -160,11 +159,7 @@ func requestHandler(w http.ResponseWriter, r *http.Request) bool {
|
|||||||
return true
|
return true
|
||||||
case "/-/reload":
|
case "/-/reload":
|
||||||
promscrapeConfigReloadRequests.Inc()
|
promscrapeConfigReloadRequests.Inc()
|
||||||
if err := syscall.Kill(syscall.Getpid(), syscall.SIGHUP); err != nil {
|
procutil.SelfSIGHUP()
|
||||||
promscrapeConfigReloadErrors.Inc()
|
|
||||||
httpserver.Errorf(w, "Fail to reload config file, %s", err)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
w.WriteHeader(http.StatusNoContent)
|
w.WriteHeader(http.StatusNoContent)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -189,5 +184,4 @@ var (
|
|||||||
promscrapeTargetsRequests = metrics.NewCounter(`vmagent_http_requests_total{path="/targets"}`)
|
promscrapeTargetsRequests = metrics.NewCounter(`vmagent_http_requests_total{path="/targets"}`)
|
||||||
|
|
||||||
promscrapeConfigReloadRequests = metrics.NewCounter(`vmagent_http_requests_total{path="/-/reload"}`)
|
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"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
// WaitForSigterm waits for either SIGTERM or SIGINT
|
// WaitForSigterm waits for either SIGTERM or SIGINT
|
||||||
@ -24,3 +26,10 @@ func WaitForSigterm() os.Signal {
|
|||||||
return sig
|
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