mirror of
https://github.com/dogkeeper886/ollama37.git
synced 2025-12-11 16:26:59 +00:00
find symlink of mac app
This commit is contained in:
27
cmd/cmd.go
27
cmd/cmd.go
@@ -526,14 +526,13 @@ func RunServer(_ *cobra.Command, _ []string) error {
|
|||||||
return server.Serve(ln)
|
return server.Serve(ln)
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkServerHeartbeat(_ *cobra.Command, _ []string) error {
|
func startMacApp(client *api.Client) error {
|
||||||
client := api.NewClient()
|
link, err := os.Readlink("/usr/local/bin/ollama")
|
||||||
if err := client.Heartbeat(context.Background()); err != nil {
|
if err != nil {
|
||||||
if strings.Contains(err.Error(), "connection refused") {
|
return err
|
||||||
if runtime.GOOS == "darwin" {
|
}
|
||||||
// if the mac app is available, start it
|
path := strings.Split(link, "Ollama.app")
|
||||||
if _, err := os.Stat("/Applications/Ollama.app"); err == nil {
|
if err := exec.Command("/usr/bin/open", "-a", path[0]+"Ollama.app").Run(); err != nil {
|
||||||
if err := exec.Command("/usr/bin/open", "-a", "/Applications/Ollama.app").Run(); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// wait for the server to start
|
// wait for the server to start
|
||||||
@@ -549,11 +548,21 @@ func checkServerHeartbeat(_ *cobra.Command, _ []string) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func checkServerHeartbeat(_ *cobra.Command, _ []string) error {
|
||||||
|
client := api.NewClient()
|
||||||
|
if err := client.Heartbeat(context.Background()); err != nil {
|
||||||
|
if !strings.Contains(err.Error(), "connection refused") {
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
if runtime.GOOS == "darwin" {
|
||||||
|
if err := startMacApp(client); err != nil {
|
||||||
|
return fmt.Errorf("could not connect to ollama app server, run 'ollama serve' to start it")
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
return fmt.Errorf("could not connect to ollama server, run 'ollama serve' to start it")
|
return fmt.Errorf("could not connect to ollama server, run 'ollama serve' to start it")
|
||||||
}
|
}
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user