aboutsummaryrefslogtreecommitdiffstats
path: root/main.go
diff options
context:
space:
mode:
authorJason Cox <me@jasoncarloscox.com>2024-02-22 20:25:16 -0500
committerRobin Jarry <robin@jarry.cc>2024-04-13 21:46:35 +0200
commit4a0bb5d1840f282989bb6b4e3ec16d3da4d5c7f7 (patch)
tree4440ae9566d38fb52ce0f12ac3fccbcf9bd10f32 /main.go
parent8312b46f144cc1bcf5b6838854df2a9b167c1c3a (diff)
downloadaerc-4a0bb5d1840f282989bb6b4e3ec16d3da4d5c7f7.tar.gz
ipc: retry failed command directly, not over IPC
If IPC fails the first time we try it, we know that no other aerc instance is running. When we retry, run the command directly instead of going through the current instance's own IPC server. Signed-off-by: Jason Cox <me@jasoncarloscox.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'main.go')
-rw-r--r--main.go20
1 files changed, 7 insertions, 13 deletions
diff --git a/main.go b/main.go
index f73ac1e9..cc65dc44 100644
--- a/main.go
+++ b/main.go
@@ -212,25 +212,19 @@ func main() {
// set the aerc version so that we can use it in the template funcs
templates.SetVersion(Version)
- enableIpc := func() {
+ endStartup := func() {
startupDone()
if len(opts.Command) == 0 {
return
}
- // retry execution
- response, err := ipc.ConnectAndExec(opts.Command)
- var errMsg string
+ // Retry execution. Since IPC has already failed, we know no
+ // other aerc instance is running; run the command directly.
+ err := app.Command(opts.Command)
if err != nil {
- errMsg = err.Error()
- } else {
- errMsg = response.Error
- }
-
- if errMsg != "" {
// no other aerc instance is running, so let
// this one stay running but show the error
- errMsg = fmt.Sprintf("Startup command (%s) failed: %s\n",
- strings.Join(opts.Command, " "), errMsg)
+ errMsg := fmt.Sprintf("Startup command (%s) failed: %s\n",
+ strings.Join(opts.Command, " "), err)
log.Errorf(errMsg)
app.PushError(errMsg)
}
@@ -265,7 +259,7 @@ loop:
// it will be ready. And in some cases, it may never be.
// At least, we can be confident that accepting IPC
// commands will not crash the whole process.
- once.Do(enableIpc)
+ once.Do(endStartup)
case callback := <-ui.Callbacks:
callback()
case <-ui.Redraw: