Nginx+uwsgi+django的后端的sock文件经常丢失,为什么会出现这样的情况?该如何解决?


uwsgi的配置文件如下


 [uwsgi]
  chdir=/home/dev/workplace/xjc
  module=xjc.wsgi:application
  #master=True
  #pidfile=/tmp/project-master.pid
  socket=/home/dev/workplace/xjc/xjc.sock
  vacuum=True
  max-requests=5000
  daemonize=/home/dev/workplace/xjc/static/log/uwsgi.log

uwsgi_params文件内容如下


 uwsgi_param     QUERY_STRING            $query_string;
uwsgi_param     REQUEST_METHOD          $request_method;
uwsgi_param     CONTENT_TYPE            $content_type;
uwsgi_param     CONTENT_LENGTH          $content_length;

uwsgi_param     REQUEST_URI             $request_uri;
uwsgi_param     PATH_INFO               $document_uri;
uwsgi_param     DOCUMENT_ROOT           $document_root;
uwsgi_param     SERVER_PROTOCOL         $server_protocol;
uwsgi_param     UWSGI_SCHEME            $scheme;

uwsgi_param     REMOTE_ADDR             $remote_addr;
uwsgi_param     REMOTE_PORT             $remote_port;
uwsgi_param     SERVER_PORT             $server_port;
uwsgi_param     SERVER_NAME             $server_name;

nginx的配置文件如下


 upstream django {
        server unix:///home/dev/workplace/xjc/xjc.sock;           
}

server {
        listen      80;
        charset     utf-8;

        client_max_body_size 75M;  

        root    /home/dev/workplace/xjc/www; 

        location /static {
                alias /home/dev/workplace/xjc/static ;
        }

        location /api {
                uwsgi_pass  django;
                include     /home/dev/workplace/xjc/uwsgi_params; 
        }

        location /admin {
                uwsgi_pass  django;
                include     /home/dev/workplace/xjc/uwsgi_params; 
        }

        location / {
                index /home/dev/workplace/xjc/www/index.html;
        }
}

python django nginx uwsgi

最爱阿露库埃德 10 years, 4 months ago

Your Answer