[英]Unable to start gunicorn.service due to import module error
I am trying to start Gunicorn from systemd service file, but I get import module error. 我正在尝试从systemd服务文件启动Gunicorn,但出现导入模块错误。 How can I fix it?
我该如何解决?
My gunicorn service file: 我的gunicorn服务档案:
[Unit]
Description=gunicorn daemon
After=network.target
[Service]
User=sammy
Group=www-data
WorkingDirectory=/home/sammy/myproject
ExecStart=/home/sammy/myproject/venv/bin/gunicorn --workers 3 --bind unix:/home/sammy/myproject/myproject.sock myproject.wsgi:application
[Install]
WantedBy=multi-user.target
When I execute gunicorn --bind 0.0.0.0:8000 myproject.wsgi:application
, there is no error. 当我执行
gunicorn --bind 0.0.0.0:8000 myproject.wsgi:application
,没有错误。
But when I use 但是当我使用
sudo systemctl start gunicorn
sudo systemctl enable gunicorn
I get this error: 我收到此错误:
ImportError: No module named 'myproject'
What is wrong? 怎么了?
It is probably a directory permission problem. 这可能是目录权限问题。 Make sure the user sammy is in the www-data group and set the home directory permissions with a chmod 710.
确保用户sammy位于www-data组中,并使用chmod 710设置主目录权限。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.