39 lines
1.3 KiB
Python
39 lines
1.3 KiB
Python
import os
|
|
import time
|
|
import psycopg2
|
|
import requests
|
|
|
|
# Налаштування (беруться з Environment Variables)
|
|
DB_HOST = os.getenv("DB_HOST", "postgres")
|
|
DB_USER = os.getenv("DB_USER", "postgres")
|
|
DB_PASS = os.getenv("DB_PASS", "password")
|
|
GRAPHITI_URL = os.getenv("GRAPHITI_URL", "http://graphiti:8000")
|
|
|
|
def check_connections():
|
|
print("🕵️ Antigravity Agent: Starting Diagnostics...")
|
|
|
|
# 1. Перевірка Graphiti (Пам'ять)
|
|
try:
|
|
r = requests.get(f"{GRAPHITI_URL}/health", timeout=3)
|
|
if r.status_code == 200:
|
|
print(f"✅ Graphiti Memory is ONLINE at {GRAPHITI_URL}")
|
|
else:
|
|
print(f"⚠️ Graphiti returned status {r.status_code}")
|
|
except Exception as e:
|
|
print(f"❌ Graphiti Connection Failed: {e}")
|
|
|
|
# 2. Перевірка Postgres (База Знань)
|
|
try:
|
|
conn = psycopg2.connect(
|
|
host=DB_HOST, user=DB_USER, password=DB_PASS, dbname="postgres"
|
|
)
|
|
print("✅ Postgres Database is CONNECTED")
|
|
conn.close()
|
|
except Exception as e:
|
|
print(f"❌ Postgres Connection Failed: {e}")
|
|
|
|
if __name__ == "__main__":
|
|
while True:
|
|
check_connections()
|
|
print("💤 Sleeping for 60 seconds...")
|
|
time.sleep(60) |