From 4419006139c0e3427a22862d948ed466be4fff4e Mon Sep 17 00:00:00 2001 From: Christophe Fergeau Date: Thu, 14 Mar 2024 16:57:50 +0100 Subject: [PATCH] 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. --- pkg/rest/rest.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/rest/rest.go b/pkg/rest/rest.go index 3db945c0..17ebef82 100644 --- a/pkg/rest/rest.go +++ b/pkg/rest/rest.go @@ -4,11 +4,13 @@ import ( "errors" "fmt" "net/url" + "os" "strings" "syscall" "github.com/crc-org/vfkit/pkg/cmdline" "github.com/gin-gonic/gin" + "github.com/onsi/gocleanup" "github.com/sirupsen/logrus" ) @@ -73,6 +75,7 @@ func (v *VFKitService) Start() { case TCP: err = v.router.Run(v.Host) case Unix: + gocleanup.Register(func() { os.Remove(v.Path) }) err = v.router.RunUnix(v.Path) } logrus.Fatal(err)