Skip to content

Instantly share code, notes, and snippets.

@SyNeto
Last active May 1, 2021 03:36
Show Gist options
  • Save SyNeto/aeb1757ac3f4e44c12c67e9e8d956782 to your computer and use it in GitHub Desktop.
Save SyNeto/aeb1757ac3f4e44c12c67e9e8d956782 to your computer and use it in GitHub Desktop.

Intructions to configure gunicorn with systemd

/etc/systemd/system/gunicorn.socket

[Unit]
Description=gunicorn socket

[Socket]
ListenStream=/run/gunicorn.sock

[Install]
WantedBy=sockets.target

/etc/systemd/system/gunicorn.service

[Unit]
Description=mi gunicorn
Requires=gunicorn.socket
After=network.target

[Service]
User=appuser
Group=www-data
WorkingDirectory=/path/to/app
ExecStart=/path/to/bin/gunicorn \
          --access-logfile - \
          --workers 3 \
          --bind unix:/run/gunicorn.sock \
          app.wsgi:application
          
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment