Advertisement
djangopdx

systemd-notes

Aug 29th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. Gunicorn Systemd documentation From the following link:
  2.  
  3. http://docs.gunicorn.org/en/stable/deploy.html
  4.  
  5. /etc/systemd/system/gunicorn.service:
  6.  
  7. [Unit]
  8. Description=gunicorn daemon
  9. Requires=gunicorn.socket
  10. After=network.target
  11.  
  12. [Service]
  13. PIDFile=/run/gunicorn/pid
  14. User=someuser
  15. Group=someuser
  16. RuntimeDirectory=gunicorn
  17. WorkingDirectory=/home/someuser/applicationroot
  18. ExecStart=/usr/bin/gunicorn --pid /run/gunicorn/pid \
  19. --bind unix:/run/gunicorn/socket applicationname.wsgi
  20. ExecReload=/bin/kill -s HUP $MAINPID
  21. ExecStop=/bin/kill -s TERM $MAINPID
  22. PrivateTmp=true
  23.  
  24. [Install]
  25. WantedBy=multi-user.target
  26. /etc/systemd/system/gunicorn.socket:
  27.  
  28. [Unit]
  29. Description=gunicorn socket
  30.  
  31. [Socket]
  32. ListenStream=/run/gunicorn/socket
  33.  
  34. [Install]
  35. WantedBy=sockets.target
  36. /etc/tmpfiles.d/gunicorn.conf:
  37.  
  38. d /run/gunicorn 0755 someuser somegroup -
  39. Next enable the socket so it autostarts at boot:
  40.  
  41. systemctl enable gunicorn.socket
  42. Either reboot, or start the services manually:
  43.  
  44. systemctl start gunicorn.socket
  45. After running curl --unix-socket /run/gunicorn/socket http, Gunicorn should start and you should see some HTML from your server in the terminal.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement