diff --git a/build_assets/macOS/README_MACOS_DEV_BUILD.md b/build_assets/macOS/README_MACOS_DEV_BUILD.md index fc1e0c5..e5e929e 100644 --- a/build_assets/macOS/README_MACOS_DEV_BUILD.md +++ b/build_assets/macOS/README_MACOS_DEV_BUILD.md @@ -33,7 +33,7 @@ For Intel (x86_64) 5. Build App for Local Installation ```shell - $ pyinstaller --windowed --add-data --name="MORagents" --icon="images/moragents.icns" --osx-entitlements-file "build_assets/macOS/MORagents.entitlements" main.py + $ pyinstaller --windowed --name="MORagents" --icon="images/moragents.icns" --osx-entitlements-file "build_assets/macOS/MORagents.entitlements" main.py ``` # If you have issues, try python -m PyInstaller --windowed --runtime-hook runtime_hook.py --name="MORagents" --icon="moragents.icns" main.py diff --git a/main.py b/main.py index e01081c..f94c23e 100644 --- a/main.py +++ b/main.py @@ -2,8 +2,8 @@ import logging import webbrowser -from runtime_setup_macos import docker_setup as docker_setup_macos -from runtime_setup_windows import docker_setup as docker_setup_windows +from runtime_setup_macos import main as macos_setup +from runtime_setup_windows import main as windows_setup from utils.logger_config import setup_logger from utils.host_utils import get_os_and_arch @@ -17,9 +17,9 @@ os_name, arch = get_os_and_arch() if os_name == "macOS": - docker_setup_macos() + macos_setup() elif os_name == "Windows": - docker_setup_windows() + windows_setup() elif os_name == "Linux": raise RuntimeError( f"MORagents needs Linux support! Would you like to help?\n" diff --git a/runtime_setup_macos.py b/runtime_setup_macos.py index 7df048a..70f2d48 100644 --- a/runtime_setup_macos.py +++ b/runtime_setup_macos.py @@ -106,6 +106,18 @@ def pull_docker_images(docker_path): logger.error(f"Failed to pull image {image}: {e}") raise +def start_ollama_server(): + ollama_path = '/usr/local/bin/ollama' + + try: + # Start Ollama server + logger.info("Starting Ollama server...") + subprocess.Popen([ollama_path, "serve"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + logger.info("Ollama server started successfully.") + except Exception as e: + logger.info("Failed to start Ollama server.") + logger.error(f"Failed to start Ollama server: {e}") + def docker_setup(): docker_path = get_docker_path() logger.info(f"Docker path: {docker_path}") @@ -141,5 +153,11 @@ def docker_setup(): AgentDockerConfig.get_current_image_names()[0] # nginx image ], check=True) +def main(): + # main() called every time the app is opened (from main.py). Put all app open code here. + logger.info("Starting app...") + start_ollama_server() + docker_setup() + if __name__ == "__main__": - docker_setup() \ No newline at end of file + main() \ No newline at end of file diff --git a/runtime_setup_windows.py b/runtime_setup_windows.py index 8bfc22f..33de5d9 100644 --- a/runtime_setup_windows.py +++ b/runtime_setup_windows.py @@ -107,6 +107,20 @@ def pull_docker_images(): logger.error(f"Failed to pull image {image_name}: {e}") raise +def start_ollama_server(): + ollama_path = "ollama" + + try: + print(f"Attempting to start Ollama server using: {ollama_path}") + subprocess.Popen([ollama_path, "serve"], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + creationflags=subprocess.CREATE_NO_WINDOW) + print("Ollama server started successfully.") + except Exception as e: + print(f"Failed to start Ollama server: {e}") + + def docker_setup(): if not check_docker_installed(): print("Docker is not installed. Please install Docker Desktop.") @@ -139,5 +153,10 @@ def docker_setup(): AgentDockerConfig.get_current_image_names()[0] # nginx image ], check=True) +def main(): + # main() called every time the app is opened (from main.py). Put all app open code here. + start_ollama_server() + docker_setup() + if __name__ == "__main__": docker_setup() \ No newline at end of file