无法从插座开始获取Gunicorn服务

时间:2019-09-30 20:32:03

标签: django unix service gunicorn systemd

我有一个Django和Gunicorn设置。如果我从这样的命令行启动Gunicorn服务:

gunicorn --bind 0.0.0.0:8000 first.wsgi

来自以下工作目录:

~/code/firstdjangoproject/first

一切正常。

但是,当我尝试使用以下systemd配置通过gunicorn.service为枪械设置服务时:

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

[Service]
User=pi
Group=www-data
WorkingDirectory=/home/pi/firstdjangoproject
ExecStart=/usr/local/bin/gunicorn \
          --access-logfile - \
          --error-logfile - /home/pi/error.log \
          --workers 3 \
          --bind unix:/run/gunicorn.sock \
          first.wsgi:application

[Install]
WantedBy=multi-user.target

尝试使用curl --unix-socket /run/gunicorn.sock localhost访问网站时出现以下错误:

curl: (56) Recv failure: Connection reset by peer

当我查看日志sudo systemctl status gunicorn时,会得到以下信息:

● gunicorn.service - gunicorn daemon
   Loaded: loaded (/etc/systemd/system/gunicorn.service; disabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Mon 2019-09-30 22:14:14 CEST; 7s ago
  Process: 3070 ExecStart=/usr/local/bin/gunicorn --access-logfile - --error-logfile - /home/pi/error.log --workers 3 --bind uni
 Main PID: 3070 (code=exited, status=210/CHROOT)

sep 30 22:14:14 raspberrypi systemd[1]: Started gunicorn daemon.
sep 30 22:14:14 raspberrypi systemd[1]: gunicorn.service: Main process exited, code=exited, status=210/CHROOT
sep 30 22:14:14 raspberrypi systemd[1]: gunicorn.service: Unit entered failed state.
sep 30 22:14:14 raspberrypi systemd[1]: gunicorn.service: Failed with result 'exit-code'.
sep 30 22:14:14 raspberrypi systemd[1]: gunicorn.service: Start request repeated too quickly.
sep 30 22:14:14 raspberrypi systemd[1]: Failed to start gunicorn daemon.
sep 30 22:14:14 raspberrypi systemd[1]: gunicorn.service: Failed with result 'exit-code'.

有人知道我在做什么错吗?

0 个答案:

没有答案