【问题标题】:Gunicorn Failed to start Service (Unknown section 'Service'. Ignoring.)Gunicorn 无法启动服务(未知部分“服务”。忽略。)
【发布时间】:2020-05-04 23:23:41
【问题描述】:

我正在使用 Nginx 在 Digital Ocean 上设置 Django 项目。我在 journalctl -u gunicorn.socket 这个命令上遇到错误。收到此错误

**

    root@vavaphysio:/var/www/html/sandbox# journalctl -u gunicorn.socket
    -- Logs begin at Mon 2020-01-06 03:17:11 UTC, end at Sat 2020-01-18 06:28:38 UTC. --
    Jan 14 12:08:43 vavaphysio systemd[1]: /etc/systemd/system/gunicorn.socket:6: Unknown section 'Service'. Ignoring.
    Jan 14 12:08:43 vavaphysio systemd[1]: gunicorn.socket: Unit has no Listen setting (ListenStream=, ListenDatagram=, ListenFIFO=, ...). Refusing.


    Jan 16 09:04:14 vavaphysio systemd[1]: Listening on gunicorn socket.
    Jan 16 09:36:44 vavaphysio systemd[1]: gunicorn.socket: Failed with result 'service-start-limit-hit'.
    Jan 16 09:53:47 vavaphysio systemd[1]: Listening on gunicorn socket.

**

这是我的 gunicorn Socket 文件

**[Unit]
Description=gunicorn socket
[Socket]
ListenStream=/run/gunicorn.sock
[Install]
WantedBy=sockets.target**

Gunicorn 服务文件:

**[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target
[Service]
User=root
Group=www-data
WorkingDirectory=/var/www/html/sandbox
ExecStart=/var/www/html/sandbox/env/bin/gunicorn \
          --access-logfile - \
          --workers 3 \
          --bind unix:/run/gunicorn.sock \
          sandbox.wsgi:application
[Install]
WantedBy=multi-user.target**

请回答。

【问题讨论】:

    标签: django nginx gunicorn digital-ocean


    【解决方案1】:

    使用此设置,您需要有文件 /var/www/html/sandbox/sandbox/wsgi.py

    因为你设置了WorkingDirectory=/var/www/html/sandbox

    ExecStart 中你写sandbox.wsgi:application

    所以 gunicorn 尝试进入 WorkingDirectory 并在那里找到 sandbox/wsgi.py

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-17
      • 2020-08-25
      • 2017-06-14
      • 2017-03-20
      • 2021-03-12
      • 2016-02-04
      相关资源
      最近更新 更多