a few fixes

This commit is contained in:
Drew Weymouth
2024-06-12 18:08:22 -07:00
parent 280030c858
commit bfb869fadc
2 changed files with 10 additions and 4 deletions
+10 -2
View File
@@ -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
-2
View File
@@ -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()