gunicorn 状态处于活动状态(已退出)但在 monit 中未显示 运行
gunicorn status is active (exited) but showing not running in monit
我正在尝试从头开始在服务器上设置一个新的 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'
我刚收到完全相同的错误消息(您是否也在学习 Digital Ocean 教程?)并花了好几个小时试图弄清楚。我不知道你是否还需要它,但也许我可以让其他人免于像我一样浪费时间。
我设法通过以下方式修复了它(经过几次不同的尝试):
停止 gunicorn:
sudo systemctl stop gunicorn
正在更改包含 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
手动删除并重建 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
正在重新加载 gunicorn 守护程序:
sudo systemctl daemon-reload
正在重启 gunicorn:
sudo systemctl start gunicorn
sudo systemctl enable gunicorn
状态变为active (running)
。基本上,在某些时候,我在没有设置适当权限的情况下安装了 gunicorn。一旦我以正确的权限重新执行了这些步骤,gunicorn 就能够按预期执行。
OBS:我的文件名为 gunicorn.service
,我相信这是默认设置。我更改为 gunicorn-project.service
以匹配 OP 的术语。
我正在尝试从头开始在服务器上设置一个新的 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'
我刚收到完全相同的错误消息(您是否也在学习 Digital Ocean 教程?)并花了好几个小时试图弄清楚。我不知道你是否还需要它,但也许我可以让其他人免于像我一样浪费时间。
我设法通过以下方式修复了它(经过几次不同的尝试):
停止 gunicorn:
sudo systemctl stop gunicorn
正在更改包含
的两个目录中的写入权限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
手动删除并重建
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
正在重新加载 gunicorn 守护程序:
sudo systemctl daemon-reload
正在重启 gunicorn:
sudo systemctl start gunicorn
sudo systemctl enable gunicorn
状态变为active (running)
。基本上,在某些时候,我在没有设置适当权限的情况下安装了 gunicorn。一旦我以正确的权限重新执行了这些步骤,gunicorn 就能够按预期执行。
OBS:我的文件名为 gunicorn.service
,我相信这是默认设置。我更改为 gunicorn-project.service
以匹配 OP 的术语。