Handles the termination of the main, display, and web threads.
(sig, frame, display_thread, ragnar_thread, web_thread)
| 272 | return 'yes' in result |
| 273 | |
| 274 | |
| 275 | @staticmethod |
| 276 | def start_display(): |
| 277 | """Start the display thread""" |
| 278 | display = Display(shared_data) |
| 279 | display_thread = threading.Thread(target=display.run) |
| 280 | display_thread.start() |
| 281 | |
| 282 | # Store display instance in shared_data for access by other modules |
| 283 | shared_data.display_instance = display |
| 284 | |
| 285 | return display_thread |
| 286 | |
| 287 | def handle_exit(sig, frame, display_thread, ragnar_thread, web_thread): |
| 288 | """Handles the termination of the main, display, and web threads.""" |
| 289 | logger.info("Received exit signal, initiating clean shutdown...") |
| 290 | |
| 291 | # Stop Ragnar instance first |
| 292 | if hasattr(shared_data, 'ragnar_instance') and shared_data.ragnar_instance: |
| 293 | shared_data.ragnar_instance.stop() |
| 294 | |
| 295 | # Set all exit flags |
| 296 | shared_data.should_exit = True |
| 297 | shared_data.orchestrator_should_exit = True |
| 298 | shared_data.display_should_exit = True |
| 299 | shared_data.webapp_should_exit = True |
| 300 | |
| 301 | # Encrypt database on shutdown if auth is configured |
| 302 | try: |
| 303 | from webapp_modern import auth_mgr |
| 304 | auth_mgr.shutdown_encrypt() |
| 305 | except Exception as e: |
| 306 | logger.error(f"Shutdown encryption failed: {e}") |
| 307 | |
| 308 | # Stop individual threads (fast timeouts - systemd will SIGKILL after 5s anyway) |
| 309 | handle_exit_display(sig, frame, display_thread, exit_process=False) |
no test coverage detected