[英]Failed to start gunicorn.service: Unit gunicorn.service not found. Ubunto 18.04
I am following this How To Set Up Django with Postgres, Nginx, and Gunicorn on Ubuntu 18.04 guide.我下面这个在Ubuntu 18.04指导如何建立与Django的Postgres的,Nginx等Gunicorn。
I have created the following file .socket我创建了以下文件 .socket
sudo nano /etc/systemd/system/gunicorn.socket
[Unit]
Description=gunicorn socket
[Socket]
ListenStream=/run/gunicorn.sock
[Install]
WantedBy=sockets.target
I have created the following file .service我创建了以下文件 .service
sudo nano /etc/systemd/system/gunicorn.service
Original RECOMENDED_FORMATTING-s in the 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
How I have formatted my own version I had my virtual environment outside of the project folder on the server我如何格式化我自己的版本我在服务器上的项目文件夹之外拥有我的虚拟环境
[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
I have also tried leaving these as originally recommended我也试过按照最初的建议离开这些
--bind unix:/run/gunicorn.sock \\
Than I have tried to execute the following code比我尝试执行以下代码
sudo systemctl start gunicorn
error message 1错误信息 1
Failed to start gunicorn.service: Unit gunicorn.service not found.
and I have also tried with 2我也试过 2
sudo systemctl start gunicorn.socket
Error message 2错误信息 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.
To solve this, I have tried为了解决这个问题,我试过了
systemctl status gunicorn.socket
Result: 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 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
Result: enabled
systemctl is-enabled gunicorn.socket
结果:已enabled
systemctl is-enabled gunicorn.service
Result: Failed to get unit file state for gunicorn.service: No such file or directory
systemctl is-enabled gunicorn.service
结果: Failed to get unit file state for gunicorn.service: No such file or directory
这修复了它:
sudo systemctl enable gunicorn.service
It cost me about three hours ... Fxxx我花了大约三个小时...... Fxxx
Don't do this:不要这样做:
sudo systemctl start gunicorn.socket
sudo systemctl enable gunicorn.socket
Do this:做这个:
sudo systemctl enable gunicorn.socket
sudo systemctl start gunicorn.socket
and:和:
sudo systemctl status gunicorn.socket
it works fine now !它现在工作正常!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.