start_darwin.go 574 B

12345678910111213141516171819202122232425262728293031
  1. package cmd
  2. import (
  3. "context"
  4. "fmt"
  5. "os"
  6. "os/exec"
  7. "strings"
  8. "github.com/ollama/ollama/api"
  9. )
  10. func startApp(ctx context.Context, client *api.Client) error {
  11. exe, err := os.Executable()
  12. if err != nil {
  13. return err
  14. }
  15. link, err := os.Readlink(exe)
  16. if err != nil {
  17. return err
  18. }
  19. if !strings.Contains(link, "Ollama.app") {
  20. return fmt.Errorf("could not find ollama app")
  21. }
  22. path := strings.Split(link, "Ollama.app")
  23. if err := exec.Command("/usr/bin/open", "-a", path[0]+"Ollama.app").Run(); err != nil {
  24. return err
  25. }
  26. return waitForServer(ctx, client)
  27. }