diff --git a/cmd/mind-map/service.go b/cmd/mind-map/service.go index 4694826..ea1f676 100644 --- a/cmd/mind-map/service.go +++ b/cmd/mind-map/service.go @@ -91,6 +91,7 @@ func newServiceConfig(addr, dir, webui string, idleTimeout time.Duration) *servi if runtime.GOOS == "darwin" { cfg.Option = service.KeyValue{ "UserService": true, + "RunAtLoad": true, } } else if runtime.GOOS == "linux" { cfg.UserName = os.Getenv("SUDO_USER") @@ -170,8 +171,12 @@ var serviceStartCmd = &cobra.Command{ return fmt.Errorf("start service: %w", err) } fmt.Println("Service started.") - fmt.Printf(" Web UI: http://%s\n", addr) - fmt.Printf(" MCP endpoint: http://%s/mcp\n", addr) + // Only print the address if explicitly provided; otherwise the plist + // may contain a different addr than the flag default. + if cmd.Flags().Changed("addr") { + fmt.Printf(" Web UI: http://%s\n", addr) + fmt.Printf(" MCP endpoint: http://%s/mcp\n", addr) + } return nil }, } diff --git a/install.sh b/install.sh index bff0e5f..4dbb351 100755 --- a/install.sh +++ b/install.sh @@ -78,8 +78,15 @@ mkdir -p "${HOME}/.mind-map" # Stop existing service before replacing the binary if [ -f "${INSTALL_DIR}/mind-map" ]; then - sudo "${INSTALL_DIR}/mind-map" service stop 2>/dev/null && \ - echo "==> Stopped existing mind-map service" || true + # On macOS the service is a user LaunchAgent; sudo would look for the plist + # under /var/root instead of ~/Library/LaunchAgents, so don't use sudo. + if [[ "$(uname -s)" == "Darwin" ]]; then + "${INSTALL_DIR}/mind-map" service stop 2>/dev/null && \ + echo "==> Stopped existing mind-map service" || true + else + sudo "${INSTALL_DIR}/mind-map" service stop 2>/dev/null && \ + echo "==> Stopped existing mind-map service" || true + fi fi echo "==> Downloading ${TARBALL_NAME}..."