MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / handle_exit

Function handle_exit

Ragnar.py:274–306  ·  view source on GitHub ↗

Handles the termination of the main, display, and web threads.

(sig, frame, display_thread, ragnar_thread, web_thread)

Source from the content-addressed store, hash-verified

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
287def 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)

Callers 1

Ragnar.pyFile · 0.70

Calls 6

handle_exit_displayFunction · 0.90
infoMethod · 0.80
shutdown_encryptMethod · 0.80
errorMethod · 0.80
exitMethod · 0.80
stopMethod · 0.45

Tested by

no test coverage detected