Fix duplicate menus on update and exit on signals

Also fixes a few fit-and-finish items for better developer experience
This commit is contained in:
Daniel Hiltgen
2024-02-16 15:33:16 -08:00
parent 88622847c6
commit df6dc4fd96
6 changed files with 52 additions and 36 deletions

View File

@@ -6,6 +6,8 @@ import (
"log"
"log/slog"
"os"
"os/signal"
"syscall"
"github.com/jmorganca/ollama/app/store"
"github.com/jmorganca/ollama/app/tray"
@@ -23,12 +25,18 @@ func Run() {
}
callbacks := t.GetCallbacks()
signals := make(chan os.Signal, 1)
signal.Notify(signals, syscall.SIGINT, syscall.SIGTERM)
go func() {
slog.Debug("starting callback loop")
for {
select {
case <-callbacks.Quit:
slog.Debug("QUIT called")
slog.Debug("quit called")
t.Quit()
case <-signals:
slog.Debug("shutting down due to signal")
t.Quit()
case <-callbacks.Update:
err := DoUpgrade(cancel, done)