Download scripts/start_all.py from dispatchAI/dispatchAI-API: direct link, hf CLI and curl.
- Browser
- Download file 2.43 kB
-
https://huggingface.co/dispatchAI/dispatchAI-API/resolve/main/scripts/start_all.py
- Command line
-
hf download hf://dispatchAI/dispatchAI-API/scripts/start_all.py
-
curl -L -o start_all.py https://huggingface.co/dispatchAI/dispatchAI-API/resolve/main/scripts/start_all.py
2.43 kB
| """ | |
| dispatchAI Startup Script - starts all services | |
| Run this when the PC boots or after a restart. | |
| """ | |
| import subprocess | |
| import time | |
| import sys | |
| import os | |
| BASE_DIR = "C:/Users/RAK/dispatch-ai" | |
| VENV_PYTHON = f"{BASE_DIR}/.venv/Scripts/python.exe" | |
| CADDY_PATH = "C:/Users/RAK/AppData/Local/Microsoft/WinGet/Packages/CaddyServer.Caddy_Microsoft.Winget.Source_8wekyb3d8bbwe/caddy.exe" | |
| def start_service(name, command, check_url=None, wait=3): | |
| """Start a background service.""" | |
| print(f" Starting {name}...", end=" ") | |
| try: | |
| proc = subprocess.Popen( | |
| command, | |
| stdout=subprocess.DEVNULL, | |
| stderr=subprocess.DEVNULL, | |
| shell=True, | |
| ) | |
| time.sleep(wait) | |
| if check_url: | |
| import urllib.request | |
| try: | |
| urllib.request.urlopen(check_url, timeout=5) | |
| print(f"OK (PID {proc.pid})") | |
| except: | |
| print(f"STARTED (PID {proc.pid}) - health check pending") | |
| else: | |
| print(f"OK (PID {proc.pid})") | |
| return proc.pid | |
| except Exception as e: | |
| print(f"FAILED: {e}") | |
| return None | |
| def main(): | |
| print("=" * 50) | |
| print("dispatchAI Startup") | |
| print("=" * 50) | |
| pids = {} | |
| # 1. API Gateway | |
| pids["gateway"] = start_service( | |
| "API Gateway", | |
| f'cd {BASE_DIR} && {VENV_PYTHON} -m uvicorn api.gateway:app --host 0.0.0.0 --port 8081', | |
| check_url="http://127.0.0.1:8081/", | |
| ) | |
| # 2. Phone Proxies | |
| phones = ["R3CN50EY64N", "R3CN50GRK5X", "R3CN50GTEYH"] | |
| for i, serial in enumerate(phones): | |
| port = 5000 + i | |
| pids[f"phone_{i}"] = start_service( | |
| f"Phone Proxy {serial}", | |
| f'cd {BASE_DIR} && {VENV_PYTHON} api/phone_proxy_v2.py {serial} {port}', | |
| check_url=f"http://127.0.0.1:{port}/health", | |
| ) | |
| # 3. Caddy (HTTPS) | |
| pids["caddy"] = start_service( | |
| "Caddy HTTPS", | |
| f'"{CADDY_PATH}" run --config {BASE_DIR}/api/Caddyfile', | |
| ) | |
| print() | |
| print("=" * 50) | |
| print("All services started!") | |
| print(f" API: http://api.dispatchai.ai:8081") | |
| print(f" HTTPS: https://api.dispatchai.ai") | |
| print(f" Phones: 3 proxies on ports 5000-5002") | |
| print("=" * 50) | |
| # Save PIDs | |
| with open(f"{BASE_DIR}/data/service_pids.json", "w") as f: | |
| import json | |
| json.dump(pids, f, indent=2) | |
| if __name__ == "__main__": | |
| main() | |