Skip to content

Instantly share code, notes, and snippets.

@Xowap
Created November 10, 2024 00:19
Show Gist options
  • Save Xowap/ff31058a808ecf93922277ed8905927e to your computer and use it in GitHub Desktop.
Save Xowap/ff31058a808ecf93922277ed8905927e to your computer and use it in GitHub Desktop.
Django with systemd
[Unit]
Description=xxx gunicorn server
Requires=xxx.socket
After=network.target
[Service]
User=www-data
Group=www-data
EnvironmentFile=/var/apps/xxx/env
WorkingDirectory=/var/apps/xxx/
PermissionsStartOnly=true
ExecStartPre=/bin/mkdir -p /run/felix
ExecStartPre=/bin/chmod 1777 /run/felix
PIDFile=/run/felix/xxx.pid
ExecStart=/var/apps/_virtualenvs/xxx/bin/gunicorn --pid /run/felix/xxx.pid --log-file - --threads 10 xxx.wsgi
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
Restart=always
RestartSec=1
PrivateTmp=true
[Install]
WantedBy=multi-user.target
[Unit]
Description=xxx socket
[Socket]
ListenStream=/run/felix/sockets/xxx.socket
[Install]
WantedBy=sockets.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment