首页 文章

启动Gunicorn时出错:“ Worker 无法启动”

提问于
浏览
0

我正在尝试用Gunicorn和Nginx将Django项目部署到DigitalOcean .

当我尝试启动Gunicorn时,我收到错误:“工作人员无法启动”

cd /opt/blog/src && /opt/blog/env/bin/gunicorn core.wsgi:application --bind 0.0.0.0:8000

错误:

gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>

这是我的项目结构:

/opt/blog/
    env/
    src/
        core/
            wsgi.py

在我的settings.py中:

DEBUG=False
ALLOWED_HOSTS = ['*']

/etc/init/gunicorn.conf:

description "Gunicorn application server handling blog."

start on runlevel [2345]
stop on runlevel [!2345]

respawn
setuid nobody
setgid nogroup
chdir /opt/blog/src

exec /opt/blog/env/bin/gunicorn --workers 3 --bind 0.0.0.0:8000 core.wsgi:application

/etc/nginx/sites-available/umutcoskun.com:

server {
    server_name umutcoskun.com www.umutcoskun.com;

    access_log off;

    location /static/ {
        alias /opt/blog/static/;
    }

    location / {
        proxy_pass http://0.0.0.0:8000;
        proxy_set_header X-Forwarded-Host $server_name;
        proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header Host $host;
        proxy_set_header X-Forwarded-Host $proxy_add_x_forwarded_for;
        add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"';
    }
}

我在哪里犯错误?

1 回答

  • 3

    当我使用“--preload”运行gunicorn命令时,我收到此错误:

    ValueError: Unable to configure root logger: Unable to add handler 'sentry': 'sentry'"
    

    然后我在settings.py中从 Logger 处理程序中删除了哨兵 . 然后错误修复 .

相关问题