mirror of
https://github.com/goauthentik/authentik.git
synced 2026-06-17 19:09:11 +03:00
internal: remove unix sockets on shutdown (#21081)
This commit is contained in:
committed by
GitHub
parent
36ef00f548
commit
bc0cbdf4b6
@@ -52,6 +52,7 @@ func RunMetricsServer(listen string, router *mux.Router) {
|
||||
func RunMetricsUnix(router *mux.Router) {
|
||||
socketPath := path.Join(os.TempDir(), MetricsSocketName)
|
||||
l := log.WithField("logger", "authentik.outpost.metrics").WithField("listen", socketPath)
|
||||
_ = os.Remove(socketPath)
|
||||
ln, err := unix.Listen(socketPath)
|
||||
if err != nil {
|
||||
l.WithError(err).Warning("failed to listen")
|
||||
@@ -59,6 +60,7 @@ func RunMetricsUnix(router *mux.Router) {
|
||||
}
|
||||
defer func() {
|
||||
err := ln.Close()
|
||||
_ = os.Remove(socketPath)
|
||||
if err != nil {
|
||||
l.WithError(err).Warning("failed to close listener")
|
||||
}
|
||||
|
||||
@@ -247,6 +247,7 @@ func (ws *WebServer) listenUnix(listen string) {
|
||||
}
|
||||
defer func() {
|
||||
err := ln.Close()
|
||||
_ = os.Remove(listen)
|
||||
if err != nil {
|
||||
ws.log.WithField("listen", listen).WithError(err).Warning("failed to close listener")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user