Skip to content

Commit 4419006

Browse files
committed
rest: Use gocleanup
When using the REST API over a unix socket, this ensures the unix socket is removed from the filesystem when vfkit exits.
1 parent 4bb5541 commit 4419006

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

pkg/rest/rest.go

+3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ import (
44
"errors"
55
"fmt"
66
"net/url"
7+
"os"
78
"strings"
89
"syscall"
910

1011
"github.com/crc-org/vfkit/pkg/cmdline"
1112
"github.com/gin-gonic/gin"
13+
"github.com/onsi/gocleanup"
1214
"github.com/sirupsen/logrus"
1315
)
1416

@@ -73,6 +75,7 @@ func (v *VFKitService) Start() {
7375
case TCP:
7476
err = v.router.Run(v.Host)
7577
case Unix:
78+
gocleanup.Register(func() { os.Remove(v.Path) })
7679
err = v.router.RunUnix(v.Path)
7780
}
7881
logrus.Fatal(err)

0 commit comments

Comments
 (0)