79def start_server(config: StressTestConfig) -> RunningProcess:
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 = RunningProcess(
90 [str(runner_path), str(dll_path)],
91 auto_run=True,
92 capture=True,
93 stderr=STDOUT,
94 encoding="utf-8",
95 errors="replace",
96 )
97
98
99 time.sleep(config.server_start_delay)
100
101
102 try:
103 with httpx.Client(timeout=config.timeout) as client:
104 response = client.get(f"http://{config.host}:{config.port}/ping")
105 if response.status_code == 200:
106 return proc
107 except KeyboardInterrupt:
108 proc.terminate()
109 proc.wait()
110 _thread.interrupt_main()
111 except Exception as e:
112 proc.terminate()
113 proc.wait()
114 console.print(f"[red]✗ Server not responsive: {e}[/red]")
115 sys.exit(1)
116
117 proc.terminate()
118 proc.wait()
119 console.print("[red]✗ Server failed to start[/red]")
120 sys.exit(1)
121
122