簡體   English   中英

無法啟動 gunicorn.service:未找到單位 gunicorn.service。 烏本托 18.04

[英]Failed to start gunicorn.service: Unit gunicorn.service not found. Ubunto 18.04

我下面這個在Ubuntu 18.04指導如何建立與Django的Postgres的,Nginx等Gunicorn。

我創建了以下文件 .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

指南中的原始 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.

為了解決這個問題,我試過了

  • 無法啟動 gunicorn.service: Unit gunicorn.service not found這指向與我正在做的完全相同的指南,除了舊版本的 linux。
  • 這不是相同的代碼,沒有回答https://askubuntu.com/questions/748836/unit-gunicorn-service-failed-to-load-no-such-file-or-directory
  • 運行: systemctl status gunicorn.socket結果: Warning: The unit file, source configuration file or drop-ins of gunicorn.socket changed on disk ● gunicorn.socket - gunicorn daemon Loaded: error (Reason: Invalid argument) Active: inactive (dead) systemctl status gunicorn.socket Warning: The unit file, source configuration file or drop-ins of gunicorn.socket changed on disk ● gunicorn.socket - gunicorn daemon Loaded: error (Reason: Invalid argument) Active: inactive (dead)
  • 運行: systemctl is-enabled gunicorn.socket結果:已enabled
  • 運行: systemctl is-enabled gunicorn.service結果: Failed to get unit file state for gunicorn.service: No such file or directory

這修復了它:

sudo systemctl enable gunicorn.service

我花了大約三個小時...... 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

它現在工作正常

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM