fix: docker hangs
Local Docker Build (Dev) / build-dev (push) Successful in 5s

This commit is contained in:
2025-10-25 12:09:23 -04:00
parent 1314ee3e70
commit ab48d485b8
2 changed files with 23 additions and 1 deletions
+11 -1
View File
@@ -587,7 +587,17 @@ class NFOGuardDatabase:
"""Close all database connections""" """Close all database connections"""
if hasattr(self._local, 'connection'): if hasattr(self._local, 'connection'):
try: try:
# For PostgreSQL, ensure all transactions are committed/rolled back
try:
# Force rollback any open transactions
self._local.connection.rollback()
except Exception:
pass
# Close the connection
self._local.connection.close() self._local.connection.close()
delattr(self._local, 'connection') delattr(self._local, 'connection')
except Exception: print("✅ Database connection closed successfully")
except Exception as e:
print(f"⚠️ Error closing database connection: {e}")
pass # Connection may already be closed pass # Connection may already be closed
+12
View File
@@ -146,6 +146,18 @@ def signal_handler(signum, frame):
_log("WARNING", f"Error closing database: {e}") _log("WARNING", f"Error closing database: {e}")
_log("INFO", "Graceful shutdown complete") _log("INFO", "Graceful shutdown complete")
# Force exit after 2 seconds if graceful shutdown doesn't work
import threading
def force_exit():
import time
time.sleep(2)
_log("WARNING", "Force exiting after timeout")
os._exit(0)
force_thread = threading.Thread(target=force_exit, daemon=True)
force_thread.start()
sys.exit(0) sys.exit(0)