Skip to content

Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.

quit sooner with single instance lock

Jeffrey Morgan963c20254e48
diff --git a/app/src/index.ts b/app/src/index.ts
index 02da8a1eb..2a8cbe8a2 100644
--- a/app/src/index.ts
+++ b/app/src/index.ts
@@ -8,7 +8,11 @@ import { analytics, id } from './telemetry'
require('@electron/remote/main').initialize()
let tray: Tray | null = null
+
const SingleInstanceLock = app.requestSingleInstanceLock()
+if (!SingleInstanceLock) {
+ app.quit()
+}
const createSystemtray = () => {
let brightModeIconPath = path.join(__dirname, '..', '..', 'assets', 'ollama_icon_dark_16x16.png')
@@ -108,53 +112,49 @@ function installCLI() {
})
}
-if (!SingleInstanceLock) {
- app.quit()
-} else {
- app.on('ready', () => {
- if (process.platform === 'darwin') {
- app.dock.hide()
-
- if (!app.isInApplicationsFolder()) {
- const chosen = dialog.showMessageBoxSync({
- type: 'question',
- buttons: ['Move to Applications', 'Do Not Move'],
- message: 'Ollama works best when run from the Applications directory.',
- defaultId: 0,
- cancelId: 1,
- })
-
- if (chosen === 0) {
- try {
- app.moveToApplicationsFolder({
- conflictHandler: conflictType => {
- if (conflictType === 'existsAndRunning') {
- dialog.showMessageBoxSync({
- type: 'info',
- message: 'Cannot move to Applications directory',
- detail:
- 'Another version of Ollama is currently running from your Applications directory. Close it first and try again.',
- })
- }
- return true
- },
- })
- return
- } catch (e) {
- console.error('Failed to move to applications folder')
- console.error(e)
- }
+app.on('ready', () => {
+ if (process.platform === 'darwin') {
+ app.dock.hide()
+
+ if (!app.isInApplicationsFolder()) {
+ const chosen = dialog.showMessageBoxSync({
+ type: 'question',
+ buttons: ['Move to Applications', 'Do Not Move'],
+ message: 'Ollama works best when run from the Applications directory.',
+ defaultId: 0,
+ cancelId: 1,
+ })
+
+ if (chosen === 0) {
+ try {
+ app.moveToApplicationsFolder({
+ conflictHandler: conflictType => {
+ if (conflictType === 'existsAndRunning') {
+ dialog.showMessageBoxSync({
+ type: 'info',
+ message: 'Cannot move to Applications directory',
+ detail:
+ 'Another version of Ollama is currently running from your Applications directory. Close it first and try again.',
+ })
+ }
+ return true
+ },
+ })
+ return
+ } catch (e) {
+ console.error('Failed to move to applications folder')
+ console.error(e)
}
}
}
+ }
- createSystemtray()
+ createSystemtray()
- if (app.isPackaged) {
- installCLI()
- }
- })
-}
+ if (app.isPackaged) {
+ installCLI()
+ }
+})
// Quit when all windows are closed, except on macOS. There, it's common
// for applications and their menu bar to stay active until the user quits