【问题标题】:Failed to start gunicorn.service: Unit gunicorn.service not found. Ubunto 18.04启动 gunicorn.service 失败:未找到单元 gunicorn.service。 Ubuntu 18.04
【发布时间】:2023-04-10 05:32:01
【问题描述】:

我正在关注this 如何在 Ubuntu 18.04 上使用 Postgres、Nginx 和 Gunicorn 设置 Django 指南。

我创建了以下文件.socket

sudo nano /etc/systemd/system/gunicorn.socket

[Unit]
Description=gunicorn socket

[Socket]
ListenStream=/run/gunicorn.sock

[Install]
WantedBy=sockets.target

我创建了以下文件 .service

sudo nano /etc/systemd/system/gunicorn.service

guide中的原RECOMENDED_FORMATTING-s

[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target


[Service]
User=sammyRECOMENDED_FORMATTING
Group=www-data
WorkingDirectory=/home/sammyRECOMENDED_FORMATTING/myprojectdirRECOMENDED_FORMATTING
ExecStart=/home/sammyRECOMENDED_FORMATTING/myprojectdirRECOMENDED_FORMATTING/myprojectenvRECOMENDED_FORMATTING/bin/gunicorn \
          --access-logfile - \
          --workers 3 \
          --bind unix:/run/gunicorn.sock \
          myprojectRECOMENDED_FORMATTING.wsgi:application

[Install]
WantedBy=multi-user.target

我如何格式化自己的版本我的虚拟环境位于服务器上的项目文件夹之外

[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target

[Service]
User=SERVER_USER
Group=www-data
WorkingDirectory=/home/SERVER_USER/MAIN_PROJECT_FOLDER
ExecStart=/home/SERVER_USER/ven/bin/gunicorn \
          --access-logfile - \
          --workers 3 \
          --bind unix:/home/SERVER_USER/MAIN_PROJECT_FOLDER/MAINAPPLICATION_FOLDER.sock \
          MAINAPPLICATION_FOLDER.wsgi:application

[Install]
WantedBy=multi-user.target

我也尝试按照最初的建议保留这些内容

--bind unix:/run/gunicorn.sock \

比我尝试执行以下代码

sudo systemctl start gunicorn

错误信息 1

Failed to start gunicorn.service: Unit gunicorn.service not found.

我也试过 2

sudo systemctl start gunicorn.socket

错误信息 2

Failed to start gunicorn.socket: Unit gunicorn.socket is not loaded properly: Invalid argument.
See system logs and 'systemctl status gunicorn.socket' for details.

为了解决这个问题,我已经尝试过

【问题讨论】:

    标签: python django ubuntu gunicorn ubuntu-18.04


    【解决方案1】:

    花了我大约三个小时...... Fxxx

    不要这样做:

      sudo systemctl start gunicorn.socket
      sudo systemctl enable gunicorn.socket
    

    这样做:

      sudo systemctl enable gunicorn.socket
      sudo systemctl start gunicorn.socket
    

    和:

      sudo systemctl status gunicorn.socket
    

    现在可以正常使用了

    【讨论】:

    • 谢谢。这是有道理的。
    【解决方案2】:

    这解决了它:

    sudo systemctl enable gunicorn.service

    【讨论】:

      猜你喜欢
      • 2017-04-04
      • 2021-11-08
      • 2019-10-24
      • 1970-01-01
      • 2018-03-25
      • 2021-06-24
      • 2020-09-21
      • 1970-01-01
      相关资源
      最近更新 更多