better docker handling for shutdown
This commit is contained in:
+1
-1
@@ -40,7 +40,7 @@ RUN mkdir -p /app/emby-plugin && \
|
||||
echo ' echo "No Emby plugins directory found - skipping plugin deployment"' >> /app/deploy-plugin.sh && \
|
||||
echo ' echo "To enable plugin deployment, bind mount your Emby plugins directory to /emby-plugins"' >> /app/deploy-plugin.sh && \
|
||||
echo 'fi' >> /app/deploy-plugin.sh && \
|
||||
echo 'exec python nfoguard.py' >> /app/deploy-plugin.sh && \
|
||||
echo 'exec python -u nfoguard.py' >> /app/deploy-plugin.sh && \
|
||||
chmod +x /app/deploy-plugin.sh
|
||||
|
||||
# Set ownership
|
||||
|
||||
+23
-6
@@ -19,6 +19,8 @@ from typing import Optional, Dict, Any, List, Set, Tuple
|
||||
import threading
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
import uvicorn
|
||||
import signal
|
||||
import sys
|
||||
|
||||
# Import our new modular components
|
||||
from core.database import NFOGuardDatabase
|
||||
@@ -2201,7 +2203,16 @@ async def debug_tmdb_lookup(imdb_id: str):
|
||||
# Main
|
||||
# ---------------------------
|
||||
|
||||
def signal_handler(signum, frame):
|
||||
"""Handle shutdown signals gracefully"""
|
||||
_log("INFO", f"Received signal {signum}, shutting down gracefully...")
|
||||
sys.exit(0)
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Register signal handlers for graceful shutdown
|
||||
signal.signal(signal.SIGTERM, signal_handler)
|
||||
signal.signal(signal.SIGINT, signal_handler)
|
||||
|
||||
_log("INFO", "Starting NFOGuard")
|
||||
_log("INFO", f"Version: {version}")
|
||||
_log("INFO", f"TV paths: {[str(p) for p in config.tv_paths]}")
|
||||
@@ -2210,9 +2221,15 @@ if __name__ == "__main__":
|
||||
_log("INFO", f"Config: manage_nfo={config.manage_nfo}, fix_mtimes={config.fix_dir_mtimes}")
|
||||
_log("INFO", f"Movie priority: {config.movie_priority}")
|
||||
|
||||
uvicorn.run(
|
||||
app,
|
||||
host="0.0.0.0",
|
||||
port=int(os.environ.get("PORT", "8080")),
|
||||
reload=False
|
||||
)
|
||||
try:
|
||||
uvicorn.run(
|
||||
app,
|
||||
host="0.0.0.0",
|
||||
port=int(os.environ.get("PORT", "8080")),
|
||||
reload=False
|
||||
)
|
||||
except KeyboardInterrupt:
|
||||
_log("INFO", "NFOGuard stopped by user")
|
||||
except Exception as e:
|
||||
_log("ERROR", f"NFOGuard crashed: {e}")
|
||||
sys.exit(1)
|
||||
Reference in New Issue
Block a user