Skip to content

Commit ab74398

Browse files
authored
Clean up unix socket (#739)
* Clean up unix socket On MacOS it seems subsequent attempts to bind to the abstract Unix socket fail without first explicitly removing it. This issue seems to be MacOS-specific as it doesn't occur on an Ubuntu VM (using `lima`). Fixes #738 Signed-off-by: Paul Thomson <[email protected]> * Add condition around socket file removal MacOS doesn't have abstract unix domain sockets, and so creates a file in the local dir which isn't removed when the server stops (due to the handling of sockets beginning with '@') This file needs to be removed on subsequent runs otherwise there's a bind error Signed-off-by: Paul Thomson <[email protected]> Signed-off-by: Paul Thomson <[email protected]>
1 parent f49be76 commit ab74398

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

cmd/app/grpc.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import (
1919
"context"
2020
"fmt"
2121
"net"
22+
"os"
23+
"runtime"
2224

2325
"github.com/goadesign/goa/grpc/middleware"
2426
ctclient "github.com/google/certificate-transparency-go/client"
@@ -108,6 +110,14 @@ func (g *grpcServer) startTCPListener() {
108110

109111
func (g *grpcServer) startUnixListener() {
110112
go func() {
113+
if runtime.GOOS != "linux" {
114+
// As MacOS doesn't have abstract unix domain sockets the file
115+
// created by a previous run needs to be explicitly removed
116+
if err := os.RemoveAll(LegacyUnixDomainSocket); err != nil {
117+
log.Logger.Fatal(err)
118+
}
119+
}
120+
111121
unixAddr, err := net.ResolveUnixAddr("unix", LegacyUnixDomainSocket)
112122
if err != nil {
113123
log.Logger.Fatal(err)

0 commit comments

Comments
 (0)