From 8f66d5b8ddc756ce7b888e826fba753b9e24c342 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Sun, 3 Mar 2019 14:09:54 +0000 Subject: [PATCH 1/2] Try to clean up UNIX admin socket --- src/yggdrasil/admin.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/yggdrasil/admin.go b/src/yggdrasil/admin.go index f8347f0..6e94149 100644 --- a/src/yggdrasil/admin.go +++ b/src/yggdrasil/admin.go @@ -402,7 +402,18 @@ func (a *admin) listen() { switch strings.ToLower(u.Scheme) { case "unix": if _, err := os.Stat(a.listenaddr[7:]); err == nil { - a.core.log.Warnln("WARNING:", a.listenaddr[7:], "already exists and may be in use by another process") + a.core.log.Debugln("Admin socket", a.listenaddr[7:], "already exists, trying to clean up") + if _, err := net.Dial("unix", a.listenaddr[7:]); err == nil { + a.core.log.Errorln("Admin socket", a.listenaddr[7:], "is already in use by another process") + os.Exit(1) + } else { + if err := os.Remove(a.listenaddr[7:]); err == nil { + a.core.log.Debugln(a.listenaddr[7:], "was cleaned up") + } else { + a.core.log.Errorln(a.listenaddr[7:], "already exists and was not cleaned up:", err) + os.Exit(1) + } + } } a.listener, err = net.Listen("unix", a.listenaddr[7:]) if err == nil { From c940bae9e3587bea0519b5b10eaecc29006fc07b Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Sun, 3 Mar 2019 14:15:01 +0000 Subject: [PATCH 2/2] Update output --- src/yggdrasil/admin.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/yggdrasil/admin.go b/src/yggdrasil/admin.go index 6e94149..211f3c2 100644 --- a/src/yggdrasil/admin.go +++ b/src/yggdrasil/admin.go @@ -404,7 +404,7 @@ func (a *admin) listen() { if _, err := os.Stat(a.listenaddr[7:]); err == nil { a.core.log.Debugln("Admin socket", a.listenaddr[7:], "already exists, trying to clean up") if _, err := net.Dial("unix", a.listenaddr[7:]); err == nil { - a.core.log.Errorln("Admin socket", a.listenaddr[7:], "is already in use by another process") + a.core.log.Errorln("Admin socket", a.listenaddr[7:], "already exists and is in use by another process") os.Exit(1) } else { if err := os.Remove(a.listenaddr[7:]); err == nil {