mirror of
https://github.com/goauthentik/authentik
synced 2026-04-25 17:15:26 +02:00
cmd/server/healthcheck: remove worker HTTP healthcheck (#18090)
* cmd/server/healthcheck: remove worker HTTP healthcheck Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space> * lint Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space> --------- Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>
This commit is contained in:
committed by
GitHub
parent
1905fbb58f
commit
a8327101c6
@@ -60,22 +60,6 @@ func checkServer() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
func splitHostPort(address string) (host, port string) {
|
||||
lastColon := strings.LastIndex(address, ":")
|
||||
if lastColon == -1 {
|
||||
return address, ""
|
||||
}
|
||||
|
||||
host = address[:lastColon]
|
||||
port = address[lastColon+1:]
|
||||
|
||||
if strings.HasPrefix(host, "[") && strings.HasSuffix(host, "]") {
|
||||
host = host[1 : len(host)-1]
|
||||
}
|
||||
|
||||
return host, port
|
||||
}
|
||||
|
||||
func checkWorker() int {
|
||||
pidB, err := os.ReadFile(workerPidFile)
|
||||
if err != nil {
|
||||
@@ -98,41 +82,6 @@ func checkWorker() int {
|
||||
log.WithError(err).Warning("failed to signal worker process")
|
||||
return 1
|
||||
}
|
||||
h := &http.Client{
|
||||
Transport: web.NewUserAgentTransport("goauthentik.io/healthcheck", http.DefaultTransport),
|
||||
}
|
||||
|
||||
host, port := splitHostPort(config.Get().Listen.HTTP)
|
||||
|
||||
if host == "0.0.0.0" || host == "::" {
|
||||
url := fmt.Sprintf("http://%s:%s/-/health/ready/", "::1", port)
|
||||
_, err := h.Head(url)
|
||||
if err != nil {
|
||||
log.WithError(err).WithField("url", url).Warning("failed to send healthcheck request")
|
||||
url := fmt.Sprintf("http://%s:%s/-/health/ready/", "127.0.0.1", port)
|
||||
res, err := h.Head(url)
|
||||
if err != nil {
|
||||
log.WithError(err).WithField("url", url).Warning("failed to send healthcheck request")
|
||||
return 1
|
||||
}
|
||||
if res.StatusCode >= 400 {
|
||||
log.WithField("status", res.StatusCode).Warning("unhealthy status code")
|
||||
return 1
|
||||
}
|
||||
}
|
||||
} else {
|
||||
url := fmt.Sprintf("http://%s:%s/-/health/ready/", host, port)
|
||||
res, err := h.Head(url)
|
||||
if err != nil {
|
||||
log.WithError(err).Warning("failed to send healthcheck request")
|
||||
return 1
|
||||
}
|
||||
if res.StatusCode >= 400 {
|
||||
log.WithField("status", res.StatusCode).Warning("unhealthy status code")
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
log.Info("successfully checked health")
|
||||
return 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user