feat(connector): [31188f42] Finalize production optimizations, filtering, and dashboard enhancements

This commit is contained in:
2026-03-05 09:48:34 +00:00
parent 63a5d84791
commit f36e9902e8
29 changed files with 1178 additions and 89 deletions

31
clear_zombies.py Normal file
View File

@@ -0,0 +1,31 @@
import sqlite3
from datetime import datetime, timedelta
DB_PATH = "/app/connector_queue.db"
def clear_all_zombies():
print("🧹 Cleaning up Zombie Jobs (PROCESSING for too long)...")
# A job that is PROCESSING for more than 10 minutes is likely dead
threshold = (datetime.utcnow() - timedelta(minutes=10)).strftime('%Y-%m-%d %H:%M:%S')
with sqlite3.connect(DB_PATH) as conn:
cursor = conn.cursor()
# 1. Identify Zombies
cursor.execute("SELECT id, updated_at FROM jobs WHERE status = 'PROCESSING' AND updated_at < ?", (threshold,))
zombies = cursor.fetchall()
if not zombies:
print("✅ No zombies found.")
return
print(f"🕵️ Found {len(zombies)} zombie jobs.")
for zid, updated in zombies:
print(f" - Zombie ID {zid} (Last active: {updated})")
# 2. Kill them
cursor.execute("UPDATE jobs SET status = 'FAILED', error_msg = 'Zombie cleared: Process timed out' WHERE status = 'PROCESSING' AND updated_at < ?", (threshold,))
print(f"✅ Successfully cleared {cursor.rowcount} zombie(s).")
if __name__ == "__main__":
clear_all_zombies()