【发布时间】:2019-09-23 01:30:18
【问题描述】:
我一直在关注这个tutorial 在 Digital Ocean 上部署我的 django 项目。我正在尝试配置gunicorn。
我的项目结构如下所示:
在我的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 的类似教程,但现在我一直遇到问题。
【问题讨论】: