【问题标题】:How to configure gunicorn service file如何配置 gunicorn 服务文件
【发布时间】:2021-10-09 16:47:28
【问题描述】:

我正在数字海洋上部署一个 django 项目。我的项目结构如下:

$/
    flo-log/
        logistics/
            settings.py
            wsgi.py
            ...
    manage.py
    ...

我的项目 gunicorn fille 如下图所示:

Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target

[Service]
User=flolog
Group=flolog
WorkingDirectory=/home/flolog/flo-log/logistics
ExecStart=/home/flolog/flologenv/bin/gunicorn \
          --access-logfile - \
          --workers 3 \
          --bind unix:/run/gunicorn.sock \
          logistics.wsgi:application

[Install]
WantedBy=multi-user.target

我创建了一个具有 sudo 权限的用户。每当我运行sudo systemctl status gunicorn 时,我都会遇到ModuleNotFoundError: no module named logistics。 而从错误的细节来看,是由于logistics.wsgi: gunicorn service file的应用组件

错误表明没有名为logistics 的模块,但是,我有一个名为logistic 的目录,其中包含wsgi 文件。请问我该如何解决这个错误?为什么他们告诉我logisticsbis 不是目录。更好的是,如何根据我的项目结构正确设置 gunicorn 服务文件的myproject.wsgi 部分

【问题讨论】:

    标签: django nginx gunicorn digital-ocean


    【解决方案1】:

    我想说看看你的项目结构。删除 flo-log 第一个文件夹,并将 Logistics 和 manage.py 放在服务器的主目录以及虚拟环境中。项目文件“Logistics”应与 home 中的 manage.py 位于同一文件夹中。

    希望对您有所帮助。

    【讨论】:

      猜你喜欢
      • 2019-09-19
      • 1970-01-01
      • 2021-08-23
      • 2018-03-25
      • 2014-02-28
      • 2011-11-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多