From bfb869fadcca1f87b1aa0ce4a82c3238c64ee815 Mon Sep 17 00:00:00 2001 From: Drew Weymouth Date: Wed, 12 Jun 2024 18:08:22 -0700 Subject: [PATCH] a few fixes --- backend/app.go | 12 ++++++++++-- backend/ipc/client.go | 2 -- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/backend/app.go b/backend/app.go index 93c4d9d..88e75f4 100644 --- a/backend/app.go +++ b/backend/app.go @@ -91,10 +91,13 @@ func StartupApp(appName, displayAppName, appVersionTag, latestReleaseURL string) a.bgrndCtx, a.cancel = context.WithCancel(context.Background()) a.readConfig() - if HaveCommandLineOptions() || !a.Config.Application.AllowMultiInstance { + if haveCLI := HaveCommandLineOptions(); haveCLI || !a.Config.Application.AllowMultiInstance { connected, err := a.checkCLIFlagsAndSendIPCMsg() if err != nil { - log.Printf("error sending IPC message: %s", err.Error()) + if haveCLI { + // we were supposed to control another instance and couldn't + log.Fatalf("error sending IPC message: %s", err.Error()) + } } if connected /* we reached the other instance at all */ { return nil, ErrAnotherInstance @@ -125,11 +128,16 @@ func StartupApp(appName, displayAppName, appVersionTag, latestReleaseURL string) }) // Start IPC server + if !a.lastWrittenCfg.Application.AllowMultiInstance { + ipc.DestroyConn() // cleanup socket possibly orphaned by crashed process + } listener, err := ipc.Listen() if err == nil { a.ipcServer = ipc.NewServer(a.PlaybackManager, a.callOnReactivate, func() { _ = a.callOnExit() }) go a.ipcServer.Serve(listener) + } else { + log.Printf("error starting IPC server: %s", err.Error()) } // OS media center integrations diff --git a/backend/ipc/client.go b/backend/ipc/client.go index 3b31ff1..b342382 100644 --- a/backend/ipc/client.go +++ b/backend/ipc/client.go @@ -4,7 +4,6 @@ import ( "context" "encoding/json" "errors" - "log" "net" "net/http" ) @@ -77,7 +76,6 @@ func (c *Client) sendRequest(path string) error { resp, err := c.httpC.Get("http://supersonic/" + path) if err != nil { - log.Printf("http err: %v\n", err) return err } defer resp.Body.Close()