# Example systemd unit for running the API WITHOUT Docker (bare-metal / VM). # Install to /etc/systemd/system/bulkmailer-api.service, then: # sudo systemctl daemon-reload # sudo systemctl enable --now bulkmailer-api # # Assumes: # - Code deployed to /opt/bulkmailer # - Python virtualenv at /opt/bulkmailer/venv (pip install -r requirements.txt) # - .env file present at /opt/bulkmailer/.env # - Postgres and Redis already running/reachable per DATABASE_URL/REDIS_URL [Unit] Description=Bulk Gmail Mailer API (gunicorn+uvicorn) After=network.target postgresql.service redis.service [Service] Type=simple User=bulkmailer Group=bulkmailer WorkingDirectory=/opt/bulkmailer EnvironmentFile=/opt/bulkmailer/.env ExecStart=/opt/bulkmailer/venv/bin/gunicorn app.main:app \ -k uvicorn.workers.UvicornWorker \ --bind 0.0.0.0:8000 \ --workers 2 \ --timeout 60 \ --access-logfile - \ --error-logfile - Restart=on-failure RestartSec=5 NoNewPrivileges=true ProtectSystem=full PrivateTmp=true [Install] WantedBy=multi-user.target