"""
FastPanel entry point — create site with Backend type: Systemd.

In the site card: Settings → Backend → Launch command:
  python3 main.py
(or, after venv:  .venv/bin/python main.py)

FastPanel sets SERVICE_PORT; nginx is configured by the panel.
"""
import os

from admin.app import app

if __name__ == "__main__":
    port = int(os.environ.get("SERVICE_PORT", "8000"))
    host = os.environ.get("HOST", "0.0.0.0")
    try:
        from waitress import serve

        serve(app, host=host, port=port, threads=4, channel_timeout=120)
    except ImportError:
        app.run(host=host, port=port, debug=False)
