(self)
| 232 | sys.exit(1) |
| 233 | |
| 234 | def _check_server_port(self): |
| 235 | server_target_port = self.args.server_port |
| 236 | logger.info(f"--- Step 2: Checking if port {server_target_port} is in use ---") |
| 237 | port_is_available = False |
| 238 | uvicorn_bind_host = "0.0.0.0" |
| 239 | if is_port_in_use(server_target_port, host=uvicorn_bind_host): |
| 240 | logger.warning(f"Port {server_target_port} is currently in use.") |
| 241 | pids_on_port = find_pids_on_port(server_target_port) |
| 242 | if pids_on_port: |
| 243 | logger.warning(f"PIDs using port {server_target_port}: {pids_on_port}") |
| 244 | if self.final_launch_mode == "debug": |
| 245 | choice = ( |
| 246 | input_with_timeout( |
| 247 | " Try to kill these processes? (y/n, 15s timeout): ", |
| 248 | 15, |
| 249 | ) |
| 250 | .strip() |
| 251 | .lower() |
| 252 | ) |
| 253 | if choice == "y": |
| 254 | all(kill_process_interactive(pid) for pid in pids_on_port) |
| 255 | time.sleep(2) |
| 256 | if not is_port_in_use( |
| 257 | server_target_port, host=uvicorn_bind_host |
| 258 | ): |
| 259 | logger.info("Port is now available.") |
| 260 | port_is_available = True |
| 261 | else: |
| 262 | logger.error("Port still in use after kill attempt.") |
| 263 | else: |
| 264 | logger.error("Headless mode: will not auto-kill processes.") |
| 265 | if not port_is_available: |
| 266 | logger.warning("Continuing anyway, Uvicorn will handle binding.") |
| 267 | else: |
| 268 | logger.debug(f"[System] Port {server_target_port} is available") |
| 269 | |
| 270 | def _resolve_auth_file_path(self): |
| 271 | if self.args.active_auth_json: |
no test coverage detected