#!/usr/bin/env python3 """ Check if Redis and PostgreSQL are available """ import os import sys from dotenv import load_dotenv # Load environment variables load_dotenv() def check_redis(): """Check if Redis is available""" try: import redis r = redis.Redis.from_url(os.environ.get('REDIS_URL', 'redis://localhost:6379/0')) r.ping() return True except: return False def check_postgresql(): """Check if PostgreSQL is available""" try: from sqlalchemy import create_engine, text db_url = os.environ.get('DATABASE_URL', 'postgresql://localhost/talk2me') engine = create_engine(db_url, pool_pre_ping=True) with engine.connect() as conn: result = conn.execute(text("SELECT 1")) result.fetchone() return True except Exception as e: print(f"PostgreSQL connection error: {e}") return False if __name__ == '__main__': redis_ok = check_redis() postgres_ok = check_postgresql() print(f"Redis: {'✓ Available' if redis_ok else '✗ Not available'}") print(f"PostgreSQL: {'✓ Available' if postgres_ok else '✗ Not available'}") if redis_ok and postgres_ok: print("\nAll services available - use full admin module") sys.exit(0) else: print("\nSome services missing - use simple admin module") sys.exit(1)