fix bugs with restarts/interrupts

The password reset daemon wasn't being closed on restarts, so an extra
pwr would be sent w/ every restart. Restarts & Interrupts (Ctrl-C)
rarely worked, as there were multiple listeners to the "RESTART"
channel, and I didn't know the message was consumed by whoever got it
first, meaning if the main thread didn't get it first, the app wouldn't
quit. Listeners are now registered, and the restart message is
re-broadcasted until everyone's got it.

Fixes #264
This commit is contained in:
Harvey Tindall
2023-06-11 19:48:03 +01:00
parent f88f71d933
commit ad40d7d8a9
6 changed files with 60 additions and 42 deletions

View File

@@ -8,6 +8,7 @@ import (
"os"
"os/signal"
"syscall"
"time"
"github.com/getlantern/systray"
)
@@ -26,6 +27,8 @@ func onExit() {
if RUNNING {
QUIT = true
RESTART <- true
// Safety Sleep (Ensure shutdown tasks get done)
time.Sleep(time.Second)
}
os.Remove(SOCK)
}