add http test | fix ctrl+c shutdown

This commit is contained in:
mario
2025-07-11 15:48:34 +07:00
parent 853cc70edb
commit 0cdd52db94
6 changed files with 138 additions and 139 deletions

25
api-app/api_cleanup.py Normal file
View File

@@ -0,0 +1,25 @@
"""
Custom cleanup utilities for the API application.
This module provides customized cleanup functions that are more compatible with FastAPI.
"""
import os
import sys
import shutil
import atexit
from config import settings
from utils.logger import setup_logger
from utils.cleanup import _cleanup_dirs, cleanup_dicom_files
# Create API cleanup logger
cleanup_logger = setup_logger("api_cleanup", "logs/api_cleanup.log")
def register_api_cleanup():
"""
Register cleanup handlers for the API application.
This avoids registering signal handlers which can conflict with FastAPI.
"""
# Only register the atexit handler, not signal handlers
atexit.register(cleanup_dicom_files)
cleanup_logger.info("Registered API cleanup handler for exit")
return True