# Nexus — Supervisor Process Guardian
# - --workers N for multi-core concurrency
# - --loop uvloop for 40-50% QPS improvement
# - --http httptools for fast HTTP parsing
#
# Install: sudo cp nexus.conf /etc/supervisor/conf.d/nexus.conf
# Start: sudo supervisorctl reread && sudo supervisorctl update && sudo supervisorctl start nexus
# Set workers: export NEXUS_WORKERS=$(nproc)
#
# *** Before deploying, replace ALL {{PLACEHOLDER}} values with your actual paths ***
# {{DEPLOY_DIR}}  = installation directory (e.g. /opt/nexus or /www/wwwroot/your.domain)
# {{VENV_DIR}}    = Python venv directory (e.g. /opt/nexus/venv)

[program:nexus]
command={{DEPLOY_DIR}}/venv/bin/uvicorn server.main:app --host 0.0.0.0 --port 8600 --workers %(ENV_NEXUS_WORKERS)s --loop uvloop --http httptools --log-level info
directory={{DEPLOY_DIR}}
user=root
autostart=true
autorestart=true
startretries=10
startsecs=5
stopwaitsecs=15
stopsignal=INT
environment=
    NEXUS_WORKERS="%(ENV_NEXUS_WORKERS)s",
    PATH="{{VENV_DIR}}/bin:%(ENV_PATH)s"
stderr_logfile=/var/log/nexus/error.log
stdout_logfile=/var/log/nexus/access.log
stderr_logfile_maxbytes=50MB
stdout_logfile_maxbytes=50MB
stderr_logfile_backups=5
stdout_logfile_backups=5
