fix: Improve Docker container shutdown handling
Local Docker Build (Dev) / build-dev (push) Successful in 3s

- Add proper signal handlers for graceful shutdown of all components
- Implement WebhookBatcher.shutdown() to properly close ThreadPoolExecutor and cancel timers
- Add NFOGuardDatabase.close() method to close thread-local database connections
- Increase uvicorn graceful shutdown timeout to 15 seconds
- Add cleanup in finally block to ensure resources are freed even if signal handler fails
- Reduce logging and server header overhead for better performance

This should resolve Docker container shutdown issues where containers don't respond to SIGTERM properly.

Bump version to 2.1.1

🤖 Generated with [Claude Code](https://claude.ai/code)
This commit is contained in:
2025-10-12 13:02:07 -04:00
parent c8fde41dfb
commit 867bd008c5
4 changed files with 86 additions and 4 deletions
+10 -1
View File
@@ -271,4 +271,13 @@ class NFOGuardDatabase:
"movies_with_video": movies_with_video,
"processing_history_count": history_count,
"database_size_mb": round(self.db_path.stat().st_size / 1024 / 1024, 2)
}
}
def close(self):
"""Close all database connections"""
if hasattr(self._local, 'connection'):
try:
self._local.connection.close()
delattr(self._local, 'connection')
except Exception:
pass # Connection may already be closed