2023-12-27 00:03:45 +00:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"os/exec"
|
|
|
|
"strings"
|
|
|
|
|
2024-03-26 20:04:17 +00:00
|
|
|
"github.com/ollama/ollama/api"
|
2023-12-27 00:03:45 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func startApp(ctx context.Context, client *api.Client) error {
|
|
|
|
exe, err := os.Executable()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
link, err := os.Readlink(exe)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if !strings.Contains(link, "Ollama.app") {
|
|
|
|
return fmt.Errorf("could not find ollama app")
|
|
|
|
}
|
|
|
|
path := strings.Split(link, "Ollama.app")
|
|
|
|
if err := exec.Command("/usr/bin/open", "-a", path[0]+"Ollama.app").Run(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return waitForServer(ctx, client)
|
|
|
|
}
|