From 272e53a1f56dcefb1b69b94af3e575d2f5e84485 Mon Sep 17 00:00:00 2001 From: Daniel Hiltgen Date: Thu, 15 Feb 2024 08:25:40 -0800 Subject: [PATCH 1/5] Prepare to distribute standalone windows executable This will be useful for our automated test riggig, and may be useful for advanced users who want to "roll their own" system service --- scripts/build_windows.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/build_windows.ps1 b/scripts/build_windows.ps1 index fae821e2905..10052590a60 100644 --- a/scripts/build_windows.ps1 +++ b/scripts/build_windows.ps1 @@ -60,6 +60,7 @@ function buildOllama() { /csp "Google Cloud KMS Provider" /kc ${env:KEY_CONTAINER} ollama.exe if ($LASTEXITCODE -ne 0) { exit($LASTEXITCODE)} } + cp .\ollama.exe .\dist\ollama-windows-amd64.exe } function buildApp() { From bb9de6037c721aa13c5fcc93f4f110172357248f Mon Sep 17 00:00:00 2001 From: Daniel Hiltgen Date: Thu, 15 Feb 2024 08:36:41 -0800 Subject: [PATCH 2/5] Prevent multiple installers running concurrently --- app/ollama.iss | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/ollama.iss b/app/ollama.iss index 97e647ccfc4..604def04591 100644 --- a/app/ollama.iss +++ b/app/ollama.iss @@ -80,6 +80,8 @@ SignTool=MySignTool SignedUninstaller=yes #endif +SetupMutex=OllamaSetupMutex + [Languages] Name: "english"; MessagesFile: "compiler:Default.isl" @@ -120,6 +122,8 @@ Type: filesandordirs; Name: "{%USERPROFILE}\.ollama" [Messages] WizardReady=Ollama Windows Preview ReadyLabel1=%nLet's get you up and running with your own large language models. +SetupAppRunningError=Another Ollama installer is running.%n%nPlease cancel or finish the other installer, then click OK to continue with this install, or Cancel to exit. + ;FinishedHeadingLabel=Run your first model ;FinishedLabel=%nRun this command in a PowerShell or cmd terminal.%n%n%n ollama run llama2 From 5208cf09b13a5630ce967e0bccd1821ac8d5309a Mon Sep 17 00:00:00 2001 From: Daniel Hiltgen Date: Thu, 15 Feb 2024 09:56:49 -0800 Subject: [PATCH 3/5] clean up some logging --- app/lifecycle/updater_windows.go | 3 ++- app/tray/wintray/eventloop.go | 5 ----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/app/lifecycle/updater_windows.go b/app/lifecycle/updater_windows.go index cc97f686ba4..f26c43c9061 100644 --- a/app/lifecycle/updater_windows.go +++ b/app/lifecycle/updater_windows.go @@ -48,7 +48,8 @@ func DoUpgrade(cancel context.CancelFunc, done chan int) error { if done != nil { <-done } else { - slog.Warn("XXX done chan was nil, not actually waiting") + // Shouldn't happen + slog.Warn("done chan was nil, not actually waiting") } slog.Debug(fmt.Sprintf("starting installer: %s %v", installerExe, installArgs)) diff --git a/app/tray/wintray/eventloop.go b/app/tray/wintray/eventloop.go index 958b78716ee..a0af978732c 100644 --- a/app/tray/wintray/eventloop.go +++ b/app/tray/wintray/eventloop.go @@ -45,7 +45,6 @@ func nativeLoop() { case 0: return default: - // slog.Debug(fmt.Sprintf("XXX dispatching message from run loop 0x%x", m.Message)) pTranslateMessage.Call(uintptr(unsafe.Pointer(m))) //nolint:errcheck pDispatchMessage.Call(uintptr(unsafe.Pointer(m))) //nolint:errcheck @@ -66,11 +65,9 @@ func (t *winTray) wndProc(hWnd windows.Handle, message uint32, wParam, lParam ui WM_MOUSEMOVE = 0x0200 WM_LBUTTONDOWN = 0x0201 ) - // slog.Debug(fmt.Sprintf("XXX in wndProc: 0x%x", message)) switch message { case WM_COMMAND: menuItemId := int32(wParam) - // slog.Debug(fmt.Sprintf("XXX Menu Click: %d", menuItemId)) // https://docs.microsoft.com/en-us/windows/win32/menurc/wm-command#menus switch menuItemId { case quitMenuID: @@ -151,7 +148,6 @@ func (t *winTray) wndProc(hWnd windows.Handle, message uint32, wParam, lParam ui slog.Debug(fmt.Sprintf("unmanaged app message, lParm: 0x%x", lParam)) } case t.wmTaskbarCreated: // on explorer.exe restarts - slog.Debug("XXX got taskbar created event") t.muNID.Lock() err := t.nid.add() if err != nil { @@ -161,7 +157,6 @@ func (t *winTray) wndProc(hWnd windows.Handle, message uint32, wParam, lParam ui default: // Calls the default window procedure to provide default processing for any window messages that an application does not process. // https://msdn.microsoft.com/en-us/library/windows/desktop/ms633572(v=vs.85).aspx - // slog.Debug(fmt.Sprintf("XXX default wndProc handler 0x%x", message)) lResult, _, _ = pDefWindowProc.Call( uintptr(hWnd), uintptr(message), From 1ba734de677331a398c77662376ddab4b5bfff8c Mon Sep 17 00:00:00 2001 From: Daniel Hiltgen Date: Thu, 15 Feb 2024 10:51:56 -0800 Subject: [PATCH 4/5] typo --- docs/windows.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/windows.md b/docs/windows.md index b43470c802e..875a3dc0ee7 100644 --- a/docs/windows.md +++ b/docs/windows.md @@ -14,7 +14,7 @@ As this is a preview release, you should expect a few bugs here and there. If you run into a problem you can reach out on [Discord](https://discord.gg/ollama), or file an [issue](https://github.com/ollama/ollama/issues). -Logs will be often be helpful in dianosing the problem (see +Logs will often be helpful in dianosing the problem (see [Troubleshooting](#troubleshooting) below) ## System Requirements From 117369aa732cdb49eea7d13bc2f581c6cab9388f Mon Sep 17 00:00:00 2001 From: Daniel Hiltgen Date: Thu, 15 Feb 2024 14:58:29 -0800 Subject: [PATCH 5/5] Exit if we detect another copy of Ollama running --- app/lifecycle/lifecycle.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/lifecycle/lifecycle.go b/app/lifecycle/lifecycle.go index 1fa9c7a8cdc..521ed74ada2 100644 --- a/app/lifecycle/lifecycle.go +++ b/app/lifecycle/lifecycle.go @@ -5,6 +5,7 @@ import ( "fmt" "log" "log/slog" + "os" "github.com/jmorganca/ollama/app/store" "github.com/jmorganca/ollama/app/tray" @@ -58,8 +59,8 @@ func Run() { } if IsServerRunning(ctx) { - slog.Debug("XXX detected server already running") - // TODO - should we fail fast, try to kill it, or just ignore? + slog.Info("Detected another instance of ollama running, exiting") + os.Exit(1) } else { done, err = SpawnServer(ctx, CLIName) if err != nil {