【问题标题】:Testing socket activation failed, Django and Gunicorn测试套接字激活失败,Django 和 Gunicorn
【发布时间】:2019-09-26 04:23:03
【问题描述】:

当我尝试这样做时:

sudo systemctl status gunicorn

答案是这样的:

Failed to dump process list, ignoring: No such file or directory
● gunicorn.socket - gunicorn socket
   Loaded: loaded (/etc/systemd/system/gunicorn.socket; enabled; vendor preset: enabled)
   Active: active (listening) since Wed 2019-09-25 04:23:44 UTC; 3min 27s ago
   Listen: /run/gunicorn.sock (Stream)
   CGroup: /system.slice/gunicorn.socket

Sep 25 04:23:44 myproject systemd[1]: Listening on gunicorn socket.
root@myproject :/myprojectdir# 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 Wed 2019-09-25 04:27:02 UTC; 13s ago
 Main PID: 25219 (code=exited, status=3)

Sep 25 04:27:02 myproject gunicorn[25219]:   File "/myprojectdir/myprojectenv/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
Sep 25 04:27:02 myproject gunicorn[25219]:     return util.import_app(self.app_uri)
Sep 25 04:27:02 myproject gunicorn[25219]:   File "/myprojectdir/myprojectenv/lib/python3.6/site-packages/gunicorn/util.py", line 350, in import_app
Sep 25 04:27:02 myproject gunicorn[25219]:     __import__(module)
Sep 25 04:27:02 myproject gunicorn[25219]: ModuleNotFoundError: No module named 'myproject'
Sep 25 04:27:02 myproject gunicorn[25219]: [2019-09-25 04:27:02 +0000] [25245] [INFO] Worker exiting (pid: 25245)
Sep 25 04:27:02 myproject gunicorn[25219]: [2019-09-25 04:27:02 +0000] [25219] [INFO] Shutting down: Master
Sep 25 04:27:02 myproject gunicorn[25219]: [2019-09-25 04:27:02 +0000] [25219] [INFO] Reason: Worker failed to boot.
Sep 25 04:27:02 myproject systemd[1]: gunicorn.service: Main process exited, code=exited, status=3/NOTIMPLEMENTED
Sep 25 04:27:02 myproject systemd[1]: gunicorn.service: Failed with result 'exit-code'.

似乎它正在尝试查找 myproject.wsgi,但我从未创建过它,而且我遵循的教程也没有提及它。 但是,它应该回答这个问题:

● gunicorn.service - gunicorn daemon
Loaded: loaded (/etc/systemd/system/gunicorn.service; disabled; vendor preset: enabled)
Active: inactive (dead)

感谢任何帮助,如果我没有展示任何有用的东西,我很抱歉,但我不知道我还能展示什么。我在 Google Cloud 中的 Ubuntu 18.04 上使用:Postgres、Nginx 和 Gunicorn。

【问题讨论】:

  • "ModuleNotFoundError: 没有名为 'hybroo' 的模块"。这是你的应用名称吗?
  • 尝试添加此插件sudo apt install uwsgi-plugin-python3 以帮助查找 wsgi 文件。这也是因为我们有一些文件/进程是系统范围的,而其他文件/进程仅在 virtualenv

标签: django linux postgresql nginx gunicorn


【解决方案1】:

Django在创建项目时默认创建Wsgi文件。它存在于名为 wsgi.py 的项目目录中。

您需要对 systemctl 服务文件进行更改,以便它可以找到 wsgi 文件。

编辑

/etc/systemd/system/gunicorn.service

并将以下内容添加到 [Service] 部分

WorkingDirectory=/path/to/your/project

【讨论】:

    猜你喜欢
    • 2011-06-20
    • 1970-01-01
    • 2011-11-15
    • 2023-03-31
    • 1970-01-01
    • 2011-02-16
    • 1970-01-01
    • 2023-04-03
    • 1970-01-01
    相关资源
    最近更新 更多