分类
Linux

Gunicorn创建systemd Socket 和Service 文件

/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=gunicorn daemon
Requires=gunicorn.socket
After=network.target

[Service]
User=root
Group=nobody
WorkingDirectory=/root/myprojectdir
ExecStart=/root/myprojectdir/myprojectenv/bin/gunicorn \
          --access-logfile - \
          --workers 3 \
          --log-level debug \
          --bind unix:/run/gunicorn.sock \
          myproject.wsgi:application


[Install]
WantedBy=multi-user.target
systemctl start gunicorn.socket
systemctl enable gunicorn.socket

修改systemd文件后需要

systemctl daemon-reload

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注