django - 如何修复 gunicorn.service:无法加载环境
问题描述
当我跑步时
sudo journalctl -u gunicorn
我得到:
Oct 14 12:49:22 django-ubuntu-helpme systemd[1]: gunicorn.service: Failed to load environment >
Oct 14 12:49:22 django-ubuntu-helpme systemd[1]: gunicorn.service: Failed to run 'start' task:>
Oct 14 12:49:22 django-ubuntu-helpme systemd[1]: gunicorn.service: Failed with result 'resourc>
Oct 14 12:49:22 django-ubuntu-helpme systemd[1]: Failed to start gunicorn daemon.
我想我的目录没有加起来。我有
/etc/systemd/system/gunicorn.service
这是:
[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target
[Service]
User=myname
Group=myname
EnvironmentFile=/home/myname/myapp/env
WorkingDirectory=/home/myname/myapp
ExecStart=/home/myname/myapp/env/bin/gunicorn \
--access-logfile - \
--workers 3 \
--bind unix:/run/gunicorn.sock \
myapp.wsgi:application
[Install]
WantedBy=multi-user.target
我正在工作的目录如下。
myapp/
有我的requirements.txt
文件,env/
和另一个app/
目录。在myapp/app
中,我有manage.py
一个 env 文件,其中包含我导出的 SECRET_KEY 和另一个app/
目录。在myapp/app/app,
我有settings.py
和wsgi.py
。
我究竟做错了什么?