cmd/cli: guarding against nil log ipc connection

The log ip connection may be nil, since it was not created if blocked by
firewall/VPN apps.

While at it, also add warning when the ipc connection could not be created.
This commit is contained in:
Cuong Manh Le
2025-02-21 00:13:24 +07:00
committed by Cuong Manh Le
parent 8db6fa4232
commit 513a6f9ec7

View File

@@ -222,10 +222,16 @@ func run(appCallback *AppCallback, stopCh chan struct{}) {
lc := &logConn{conn: conn}
consoleWriter.Out = io.MultiWriter(os.Stdout, lc)
p.logConn = lc
} else {
mainLog.Load().Warn().Err(err).Msgf("unable to create log ipc connection")
}
} else {
mainLog.Load().Warn().Err(err).Msgf("unable to resolve socket address: %s", sockPath)
}
notifyExitToLogServer := func() {
_, _ = p.logConn.Write([]byte(msgExit))
if p.logConn != nil {
_, _ = p.logConn.Write([]byte(msgExit))
}
}
if daemon && runtime.GOOS == "windows" {