Skip to content

Commit

Permalink
Clean up unix socket (#739)
Browse files Browse the repository at this point in the history
* 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 <thomsonp83@gmail.com>

* 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 <thomsonp83@gmail.com>

Signed-off-by: Paul Thomson <thomsonp83@gmail.com>
  • Loading branch information
pauldthomson committed Aug 20, 2022
1 parent f49be76 commit ab74398
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cmd/app/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (
"context"
"fmt"
"net"
"os"
"runtime"

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

func (g *grpcServer) startUnixListener() {
go func() {
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)
if err != nil {
log.Logger.Fatal(err)
Expand Down

0 comments on commit ab74398

Please sign in to comment.