Python 正在尝试配置gunicorn
我一直遵循这一点,在数字海洋上部署我的django项目。我正在尝试配置 我的项目结构与此类似: 在我的Python 正在尝试配置gunicorn,python,django,gunicorn,Python,Django,Gunicorn,我一直遵循这一点,在数字海洋上部署我的django项目。我正在尝试配置 我的项目结构与此类似: 在我的settings.py上,我使用DEBUG=False 我创建gunicorn.socket和gunicorn.service /etc/systemd/system/gunicorn.socket [Unit] Description=gunicorn socket [Socket] ListenStream=/run/gunicorn.sock [Install] WantedBy=s
settings.py上,我使用DEBUG=False
我创建gunicorn.socket和gunicorn.service
/etc/systemd/system/gunicorn.socket
[Unit]
Description=gunicorn socket
[Socket]
ListenStream=/run/gunicorn.sock
[Install]
WantedBy=sockets.target
/etc/systemd/system/gunicorn.service
[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target
[Service]
User=someuser
Group=www-data
WorkingDirectory=/home/someuser/myproject
ExecStart=/home/someuser/myproject/myprojectenv/bin/gunicorn \
--access-logfile - \
--workers 3 \
--bind unix:/run/gunicorn.sock \
Myproject.wsgi:application
[Install]
WantedBy=multi-user.target
我启动并启用Gunicorn插座:
sudo systemctl start gunicorn.socket
sudo systemctl enable gunicorn.socket
检查流程的状态,以确定其是否能够启动:
sudo systemctl status gunicorn.socket
这就是我得到的,然后它返回到命令行
Failed to dump process list, ignoring: No such file or directory
β—� gunicorn.socket - gunicorn socket
Loaded: loaded (/etc/systemd/system/gunicorn.socket; enabled; vendor preset: enabled)
Active: active (listening) since Sat 2019-05-04 23:12:03 UTC; 13s ago
Listen: /run/gunicorn.sock (Stream)
CGroup: /system.slice/gunicorn.socket
May 04 23:12:03 myproject systemd[1]: Listening on gunicorn socket.
接下来,我检查/run目录中是否存在gunicorn.sock文件:
file /run/gunicorn.sock
/run/gunicorn.sock: socket
似乎文件或目录不存在,但它不提供任何详细信息。gunicorn.sock似乎存在
我熟悉Python,但不熟悉服务器和部署,因此在这里我感到无所适从
几个月前,我成功地学习了Ubuntu 16.04的类似教程,但现在我不断遇到问题。这实际上是您使用systemd的一个问题。您需要在对systemctl
的调用中引用服务的名称,而不是您正在执行的套接字。在您的情况下,服务将被称为gunicorn
,因为您已将系统单位文件命名为gunicorn.service
systemctl enable gunicorn
systemctl start gunicorn
这实际上是您使用systemd
的一个问题。您需要在对systemctl
的调用中引用服务的名称,而不是您正在执行的套接字。在您的情况下,服务将被称为gunicorn
,因为您已将系统单位文件命名为gunicorn.service
systemctl enable gunicorn
systemctl start gunicorn
我知道,这是个老问题,但是。。。
我犯了一些错误。在我的例子中,modul wsgi的工作目录和应用程序是错误的。我认为这是“myproject.wsgi:application”中的错误我知道,这是个老问题,但是。。。
我犯了一些错误。在我的例子中,modul wsgi的工作目录和应用程序是错误的。我想这是“myproject.wsgi:application”中的错误。您知道如何获取有关错误的更多详细信息:“未能转储进程列表,忽略:没有这样的文件或目录”?您知道如何获取有关错误的更多详细信息:“未能转储进程列表,忽略:没有这样的文件或目录”?