我是跟随这如何与Postgres,Nginx和Gunicorn在Ubuntu18.04指南上设置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
原始RECOMENDED_格式化-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.
为了解决这个问题,我尝试了
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
发布于 2020-03-24 21:55:59
这个问题解决了:
sudo systemctl enable gunicorn.service
发布于 2021-07-23 15:55:24
花了我三个小时..。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
,,它现在工作得很好!
https://stackoverflow.com/questions/60837998
复制相似问题