# FastAPI (Gunicorn) service for /var/www/boundary-fastapiandnextjs # IMPORTANT: Use aumentum_api:app (root-level stub). Do NOT use main:app (ModuleNotFoundError). # Use 2 workers on 2GB RAM; 3 on 4GB. See docs/PRODUCTION_FASTAPI_OOM.md # # Install / fix "No module named 'main'": # sudo cp /var/www/boundary-fastapiandnextjs/scripts/fastapi.service /etc/systemd/system/fastapi.service # sudo systemctl daemon-reload # sudo systemctl restart fastapi [Unit] Description=FastAPI Application (Boundary Commission) After=network.target [Service] Type=simple User=root WorkingDirectory=/var/www/boundary-fastapiandnextjs EnvironmentFile=-/var/www/boundary-fastapiandnextjs/.env Environment=PYTHONUNBUFFERED=1 # Must be aumentum_api:app (not main:app). Uses gunicorn.conf.py for workers, bind 127.0.0.1:8001 ExecStart=/var/www/boundary-fastapiandnextjs/venv/bin/gunicorn -c gunicorn.conf.py aumentum_api:app Restart=always RestartSec=5 # Optional: cap memory so OOM killer hits this service first and restarts it instead of killing SSH # MemoryMax=1536M [Install] WantedBy=multi-user.target