【问题标题】:Unable to start gunicorn.service due to import module error由于导入模块错误,无法启动 gunicorn.service
【发布时间】:2017-04-29 13:02:36
【问题描述】:

我正在尝试从 systemd 服务文件启动 Gunicorn,但出现导入模块错误。我该如何解决?

我的 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

当我执行gunicorn --bind 0.0.0.0:8000 myproject.wsgi:application时,没有错误。

但是当我使用时

sudo systemctl start gunicorn
sudo systemctl enable gunicorn

我收到此错误:

ImportError: No module named 'myproject'

怎么了?

【问题讨论】:

  • 改进的格式,在乞讨帖子时陈述问题

标签: python django gunicorn systemd


【解决方案1】:

可能是目录权限问题。确保用户 sammy 在 www-data 组中,并使用 chmod 710 设置主目录权限。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-18
    • 1970-01-01
    • 2022-03-07
    • 1970-01-01
    • 2018-01-08
    • 1970-01-01
    相关资源
    最近更新 更多