37 lines
1.4 KiB
Python
37 lines
1.4 KiB
Python
"""Passenger / cPanel WSGI entry point.
|
|
|
|
cPanel's Python Application uses Phusion Passenger which only speaks WSGI.
|
|
Sanad_lite is FastAPI/ASGI, so this adapter wraps it with a2wsgi.
|
|
|
|
Caveat: WebSocket routes (/ws/logs) will NOT work over WSGI — the live
|
|
log-tail card in Settings & Logs will silently fail to connect. Everything
|
|
else (login, records, typed-replay, scripts, prompt) works fine.
|
|
|
|
If you want WebSockets too, deploy via Path B in the README (uvicorn
|
|
standalone + reverse proxy) instead of this Passenger setup.
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
|
|
# Make the app directory importable.
|
|
_APP_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
if _APP_DIR not in sys.path:
|
|
sys.path.insert(0, _APP_DIR)
|
|
|
|
# Run main.py's module-level bootstrap — this sets up the Project.Sanad
|
|
# alias, constructs Brain + voice_client + typed_replay, attaches them.
|
|
# Routes import these globals via `from Project.Sanad.main import ...`.
|
|
import main # noqa: F401
|
|
|
|
# main.py only sets sys.modules["Project.Sanad.main"] under its
|
|
# `if __name__ == "__main__"` guard. Under Passenger we import it as a
|
|
# module, so replicate that alias by hand.
|
|
sys.modules.setdefault("Project.Sanad.main", sys.modules["main"])
|
|
|
|
# Wrap the FastAPI ASGI app as WSGI.
|
|
from Project.Sanad.dashboard.app import app as _fastapi_app # noqa: E402
|
|
from a2wsgi import ASGIMiddleware # noqa: E402
|
|
|
|
application = ASGIMiddleware(_fastapi_app)
|