Skip to content

Commit

Permalink
Add condition around socket file removal
Browse files Browse the repository at this point in the history
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 <thomsonp83@gmail.com>
  • Loading branch information
pauldthomson committed Aug 17, 2022
1 parent 3b1856e commit 5cd969c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions cmd/app/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"fmt"
"net"
"os"
"runtime"

"github.com/goadesign/goa/grpc/middleware"
ctclient "github.com/google/certificate-transparency-go/client"
Expand Down Expand Up @@ -109,8 +110,12 @@ func (g *grpcServer) startTCPListener() {

func (g *grpcServer) startUnixListener() {
go func() {
if err := os.RemoveAll(LegacyUnixDomainSocket); err != nil {
log.Logger.Fatal(err)
if runtime.GOOS != "linux" {
// As MacOS doesn't have abstract unix domain sockets the file
// created by a previous run needs to be explicitly removed
if err := os.RemoveAll(LegacyUnixDomainSocket); err != nil {
log.Logger.Fatal(err)
}
}

unixAddr, err := net.ResolveUnixAddr("unix", LegacyUnixDomainSocket)
Expand Down

0 comments on commit 5cd969c

Please sign in to comment.