"""WSGI entry point for gunicorn. Run with: gunicorn --workers 2 --bind 0.0.0.0:5200 wsgi:app Or via systemd unit. """ import os # Ensure instance dir exists before app imports (it references the SQLite path) BASE_DIR = os.path.dirname(os.path.abspath(__file__)) os.makedirs(os.path.join(BASE_DIR, "instance"), exist_ok=True) os.makedirs(os.path.join(BASE_DIR, "backups"), exist_ok=True) from app import app, db, seed_admin with app.app_context(): try: db.create_all() seed_admin() except Exception as e: # multi-worker race - the first worker wins; subsequent ones log print(f"[wsgi] DB init: {e} (likely race with another worker)")