我改变了我的Django项目布局。现在它看起来像:
在/home/myuser/
我有一个名为myproject
的文件夹,在此文件夹中有两个文件夹:env
和site
。并且site
文件夹布局如下所示:
`+ apps
-- accounts
-- mainp
-- business
+ config
-- wsgi.py
-- urls.py
++ settings
-- base.py
-- prod.py
-- local.py
问题在于gunicorn systemd file
。这是它的内容:
[Unit]
Description=gunicorn daemon
After=network.target
[Service]
User=myuser
Group=www-data
WorkingDirectory=/home/myuser/myproject
ExecStart=/home/myuser/myproject/env/bin/gunicorn --access-logfile - --workers 4 --bind unix:/home/myuser/myproject/site/site.sock site.config.wsgi:application
[Install]
WantedBy=multi-user.target
当我重新加载并在sudo systemctl status gunicorn
之后重新启动gunicorn之后,我看到了这个错误:
Jun 11 16:11:04 site gunicorn[13589]: ImportError: No module named 'config'
Jun 11 16:11:04 site gunicorn[13589]: [2018-06-11 16:11:04 +0430] [13600]
[INFO] Worker exiting (pid: 13600)
Jun 11 16:11:04 site systemd[1]: gunicorn.service: Main process exited,
code=exited, status=1/FAILURE
Jun 11 16:11:04 site systemd[1]: gunicorn.service: Unit entered failed
state.
Jun 11 16:11:04 site systemd[1]: gunicorn.service: Failed with result
'exit-code'.
问题是什么?我该如何解决呢?