Start HTTP server in background.
(config: StressTestConfig)
| 77 | |
| 78 | |
| 79 | def start_server(config: StressTestConfig) -> subprocess.Popen[str]: |
| 80 | """Start HTTP server in background.""" |
| 81 | runner_path = Path(".build/meson-quick/examples/example_runner.exe").absolute() |
| 82 | dll_path = Path(".build/meson-quick/examples/example-Server.dll").absolute() |
| 83 | |
| 84 | if not runner_path.exists() or not dll_path.exists(): |
| 85 | console.print("[red]✗ Server executable not found - compile first:[/red]") |
| 86 | console.print(" bash test Server --examples --build") |
| 87 | sys.exit(1) |
| 88 | |
| 89 | proc = subprocess.Popen( |
| 90 | [str(runner_path), str(dll_path)], |
| 91 | stdout=subprocess.PIPE, |
| 92 | stderr=subprocess.STDOUT, |
| 93 | text=True, |
| 94 | ) |
| 95 | |
| 96 | # Wait for server to start |
| 97 | time.sleep(config.server_start_delay) |
| 98 | |
| 99 | # Verify server is responsive |
| 100 | try: |
| 101 | with httpx.Client(timeout=config.timeout) as client: |
| 102 | response = client.get(f"http://{config.host}:{config.port}/ping") |
| 103 | if response.status_code == 200: |
| 104 | return proc |
| 105 | except KeyboardInterrupt: |
| 106 | proc.terminate() |
| 107 | proc.wait() |
| 108 | _thread.interrupt_main() |
| 109 | except Exception as e: |
| 110 | proc.terminate() |
| 111 | proc.wait() |
| 112 | console.print(f"[red]✗ Server not responsive: {e}[/red]") |
| 113 | sys.exit(1) |
| 114 | |
| 115 | proc.terminate() |
| 116 | proc.wait() |
| 117 | console.print("[red]✗ Server failed to start[/red]") |
| 118 | sys.exit(1) |
| 119 | |
| 120 | |
| 121 | def make_request( |