Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django 如何在帝皇模式下配置多个uwsgi附庸(带WebSocket)的nginx?_Django_Nginx_Uwsgi - Fatal编程技术网

Django 如何在帝皇模式下配置多个uwsgi附庸(带WebSocket)的nginx?

Django 如何在帝皇模式下配置多个uwsgi附庸(带WebSocket)的nginx?,django,nginx,uwsgi,Django,Nginx,Uwsgi,我在nginx服务器后面以皇帝模式运行2个附庸(对于主应用程序+websocket)时遇到问题。一切似乎都运行良好,但所有websocket请求都返回错误502 bad gateway。websocket应用程序正在运行。知道我哪里出错了吗 从暴发户跑出来 exec /usr/local/bin/uwsgi --emperor /etc/uwsgi/vassals/ --logto /var/log/uwsgi.log 使用/etc/uwsgi/vassals/dashdb\u websock

我在nginx服务器后面以皇帝模式运行2个附庸(对于主应用程序+websocket)时遇到问题。一切似乎都运行良好,但所有websocket请求都返回错误502 bad gateway。websocket应用程序正在运行。知道我哪里出错了吗

从暴发户跑出来

exec /usr/local/bin/uwsgi --emperor /etc/uwsgi/vassals/ --logto /var/log/uwsgi.log
使用
/etc/uwsgi/vassals/dashdb\u websocket.ini

# dashdb_websocket.ini file

[uwsgi]
umask = 002
home = /opt/dashdb/venv/dashdb-3.5
plugin = python35
chdir = /opt/dashdb
master = true
no-orphans = true
die-on-term = true
memory-report = true
env = DJANGO_SETTINGS_MODULE=dashdb.settings.opener
socket = /var/run/uwsgi/dashdb_ws.sock
pythonpath = /opt/dashdb
module = dashdb.wsgi_websocket
threads = 1
processes = 1
http-websockets = true
gevent = 1000
# Log file location
daemonize = /var/log/uwsgi/dashdb_websocket.log
# dashdb.ini file

[uwsgi]

# Django-related settings
# the base directory (full path)
chdir           = /opt/%n
# Django's wsgi file
module          = dashdb.wsgi
# the virtualenv (full path)
home            = /opt/dashdb/venv/%n-3.5
plugin          = python35
# settings location
env             = DJANGO_SETTINGS_MODULE=dashdb.settings.opener


# Process-related settings
# master
master          = true
# maximum number of worker processes
processes       = 3
# the socket (use the full path to be safe)
socket          = /var/run/uwsgi/%n.sock
# ... with appropriate permissions - may be needed
chmod-socket    = 666
# clear environment on exit
vacuum          = true
# Log file location
daemonize       = /var/log/uwsgi/%n.log
使用
/etc/uwsgi/vassals/dashdb.ini

# dashdb_websocket.ini file

[uwsgi]
umask = 002
home = /opt/dashdb/venv/dashdb-3.5
plugin = python35
chdir = /opt/dashdb
master = true
no-orphans = true
die-on-term = true
memory-report = true
env = DJANGO_SETTINGS_MODULE=dashdb.settings.opener
socket = /var/run/uwsgi/dashdb_ws.sock
pythonpath = /opt/dashdb
module = dashdb.wsgi_websocket
threads = 1
processes = 1
http-websockets = true
gevent = 1000
# Log file location
daemonize = /var/log/uwsgi/dashdb_websocket.log
# dashdb.ini file

[uwsgi]

# Django-related settings
# the base directory (full path)
chdir           = /opt/%n
# Django's wsgi file
module          = dashdb.wsgi
# the virtualenv (full path)
home            = /opt/dashdb/venv/%n-3.5
plugin          = python35
# settings location
env             = DJANGO_SETTINGS_MODULE=dashdb.settings.opener


# Process-related settings
# master
master          = true
# maximum number of worker processes
processes       = 3
# the socket (use the full path to be safe)
socket          = /var/run/uwsgi/%n.sock
# ... with appropriate permissions - may be needed
chmod-socket    = 666
# clear environment on exit
vacuum          = true
# Log file location
daemonize       = /var/log/uwsgi/%n.log
和nginx配置:

upstream django_dashdb {
    server unix:/var/run/uwsgi/dashdb.sock;
}


server {
    listen *:80;
    server_name MY_DOMAIN;
    server_tokens off;
    root /opt/dashdb;
    charset utf-8;

    # Increase this if you want to upload large attachments
    # Or if you want to accept large git objects over http
    client_max_body_size 250m;


    # Individual nginx logs for this GitLab vhost
    access_log  /var/log/dashdb/dashdb_access.log;
    error_log   /var/log/dashdb/dashdb_error.log;

    # Django media
    location /media  {
        alias /opt/dashdb/media;
    }

    # Django static
    location /static {
        alias /opt/dashdb/static;
    }

    location / {
        uwsgi_read_timeout 180;
        uwsgi_pass  django_dashdb;
        include     /opt/dashdb/uwsgi_params;
    }

        location /ws/ {
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_pass http://unix:/var/run/uwsgi/dashdb_ws.sock;
    }

    error_page 502 /502.html;
}
日志中的错误:

2017/03/20 23:27:51 [error] 3586#3586: *2759 upstream prematurely closed connection while reading response header from upstream, client:
10.31.32.22, server: MY_DOMAIN...com, request: "GET /ws/builds?subscribe-broadcast&echo HTTP/1.1", upstream: "http://unix:/var/run/uwsgi/dashdb_ws.sock:/ws/builds?subscribe-broadcast&echo", host: "MY_DOMAIN...com"
我需要设置

http-socket = /var/run/uwsgi/dashdb_ws.sock
而不是

socket = /var/run/uwsgi/dashdb_ws.sock
在websocket uwsgi配置ini中