【问题标题】:gunicorn status is active (exited) but showing not running in monitgunicorn 状态处于活动状态(已退出)但显示未在监视器中运行
【发布时间】:2016-11-17 04:45:33
【问题描述】:

我正在尝试从头开始在服务器上设置一个新的 django 项目(django+gunicorn+nginx),除了 gunicorn 的初始化脚本之外,我的一切都是正确的。

如果我手动运行 gunicorn 命令,它可以工作,我可以在 ip 地址上查看我的网站,但是当我尝试执行 service gunicorn start 时,它会给出这个输出,但它不起作用...

gunicorn-project.service
   Loaded: loaded (/etc/init.d/gunicorn-project; bad; vendor preset: enabled)
   Active: active (exited) since Thu 2016-11-17 04:23:56 UTC; 17min ago
     Docs: man:systemd-sysv-generator(8)
  Process: 1656 ExecStart=/etc/init.d/gunicorn-project start (code=exited, status=0/SUCCESS)
    Tasks: 0
   Memory: 0B
      CPU: 0

Nov 17 04:23:56 project gunicorn-project[1656]:   from multiprocessing import cpu_count
Nov 17 04:23:56 project gunicorn-project[1656]: /etc/gunicorn.d/gunicorn-project2.py:3: RuntimeWarning: Parent module '/
Nov 17 04:23:56 project gunicorn-project[1656]:   from os import environ
Nov 17 04:23:56 project gunicorn-project[1656]: /etc/gunicorn.d/gunicorn-project3.py:2: RuntimeWarning: Parent module '
Nov 17 04:23:56 project gunicorn-project[1656]:   from multiprocessing import cpu_count
Nov 17 04:23:56 project gunicorn-project[1656]: /etc/gunicorn.d/gunicorn-project3.py:3: RuntimeWarning: Parent module '
Nov 17 04:23:56 project gunicorn-project[1656]:   from os import environ
Nov 17 04:23:56 project gunicorn-project[1656]:  *
Nov 17 04:23:56 project systemd[1]: Started gunicorn-project.service.
Nov 17 04:25:01 project systemd[1]: Started gunicorn-project.service.

我不知道为什么会这样……这是输出中的文件引用……

"""gunicorn WSGI server configuration."""
from multiprocessing import cpu_count
from os import environ


def max_workers():
    return cpu_count() * 2 + 1

max_requests = 1000
worker_class = 'gevent'
workers = max_workers()
errorlog = '/home/gunicorn-project/log/gunicorn/error.log'
accesslog = '/home/gunicorn-project/log/gunicorn/access.log' 

【问题讨论】:

    标签: python linux django gunicorn init


    【解决方案1】:

    我刚刚收到了同样的错误消息(您是否也在关注 Digital Ocean 教程?)并花了好几个小时试图弄清楚。我不知道你是否还需要它,但也许我可以避免其他人像我一样浪费时间。

    我设法通过以下方式修复它(经过几次不同的尝试):

    1. 停止独角兽:

      sudo systemctl stop gunicorn

    2. 在包含gunicorn.service的两个目录中更改写入权限:

      sudo chmod u+x /etc/systemd/system/multi-user.target.wants/gunicorn-project.service

      sudo chmod u+x /etc/systemd/system/gunicorn-project.service

    3. 手动删除和重建gunicorn-project.service 符号链接:

      unlink /etc/systemd/system/multi-user.target.wants/gunicorn-project.service

      rm /etc/systemd/system/multi-user.target.wants/gunicorn-project.service

      ln -s /etc/systemd/system/gunicorn-project.service /etc/systemd/system/multi-user.target.wants/gunicorn-project.service

    4. 重新加载 gunicorn 守护进程:

      sudo systemctl daemon-reload

    5. 重启 gunicorn:

      sudo systemctl start gunicorn

      sudo systemctl enable gunicorn

    并且状态更改为active (running)。基本上,在某些时候,我在没有设置适当权限的情况下安装了 gunicorn。一旦我使用正确的权限重新执行了这些步骤,gunicorn 就能够按预期执行。

    OBS:我的文件名为gunicorn.service,我相信这是默认的。我更改为 gunicorn-project.service 以匹配 OP 的术语。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-18
      • 2014-02-28
      • 2021-07-13
      • 2022-10-13
      • 2021-06-04
      相关资源
      最近更新 更多