systemd+gunicorn
code:django-gunicorn-app.service
# /etc/systemd/system/django-gunicorn-app.service
Description=django-gunicorn-app
After=network.target
PIDFile=/run/django-gunicorn-app/pid
User=www
Group=www
EnvironmentFile=/var/www/django-gunicorn-app/.env
WorkingDirectory=/var/www/django-gunicorn-app/apps
SyslogIdentifier=django-gunicorn-app
ExecStart=/var/www/django-gunicorn-app/venv/bin/gunicorn \
--pid /run/django-gunicorn-app/pid \
--workers 4 \
--max-requests 1000 \
--max-requests-jitter 50 \
--timeout=300 \
--keep-alive=24 \
--bind 127.0.0.1:8000 \
--access-logfile - \
--capture-output \
apps.wsgi:application
ExecReload=/bin/kill -s HUP $MAINPID
KillMode=mixed
Restart=always
PrivateTmp=true
WantedBy=multi-user.target
参考