mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-10 05:10:26 +00:00
Try to clean up UNIX admin socket
This commit is contained in:
parent
8342dfc6d5
commit
8f66d5b8dd
@ -402,7 +402,18 @@ func (a *admin) listen() {
|
|||||||
switch strings.ToLower(u.Scheme) {
|
switch strings.ToLower(u.Scheme) {
|
||||||
case "unix":
|
case "unix":
|
||||||
if _, err := os.Stat(a.listenaddr[7:]); err == nil {
|
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:])
|
a.listener, err = net.Listen("unix", a.listenaddr[7:])
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user