uwsgi + nginx + flask: upstream prematuramente fechado após o download do arquivo

1

Eu criei um endpoint no meu frasco que gera uma planilha a partir de uma consulta de banco de dados (banco de dados remoto) e depois a envia como um download no navegador. O frasco não apresenta nenhum erro. Uwsgi não reclama.

Mas quando eu verifico error.log do nginx eu vejo muito

2014/12/10 05:06:24 [error] 14084#0: *239436 upstream prematurely closed connection while reading response header from upstream, client: 34.34.34.34, server: me.com, request: "GET /download/export.csv HTTP/1.1", upstream: "uwsgi://0.0.0.0:5002", host: "me.com", referrer: "https://me.com/download/export.csv"

Eu implanto o uwsgi como

uwsgi --socket 0.0.0.0:5002 --buffer-size=32768 --module server --callab app

minha configuração do nginx:

server {
     listen 80;
     merge_slashes off;
     server_name me.com www.me.cpm;

     location / { try_files $uri @app; }
       location @app {
          include uwsgi_params;
          uwsgi_pass 0.0.0.0:5002;
          uwsgi_buffer_size 32k;
          uwsgi_buffers 8 32k;
          uwsgi_busy_buffers_size 32k;
     }

}

server {
      listen 443;
      merge_slashes off;
      server_name me.com www.me.com;

    location / { try_files $uri @app; }
       location @app {
          include uwsgi_params;
          uwsgi_pass 0.0.0.0:5002;
          uwsgi_buffer_size 32k;
          uwsgi_buffers 8 32k;
          uwsgi_busy_buffers_size 32k;
       }
}

Este é um problema do nginx ou uwsgi, ou ambos?

Veja o que o uwsgi diz sobre o início

    *** Starting uWSGI 2.0 (64bit) on [Wed Dec 10 15:20:23 2014] *** compiled with version: 4.6.3 on 20 January 2014 16:57:53 os: Linux-3.8.0-29-generic #42~precise1-Ubuntu SMP Wed Aug 14 16:19:23 UTC 
2013 nodename: me.com machine: x86_64 clock source: unix detected number of CPU cores: 1 current 
working directory: /home/server.py detected binary path: /usr/local/bin/uwsgi !!! no internal routing
 support, rebuild with pcre support !!! your processes number limit is 3781 your memory page size is 4096 bytes detected max file descriptor number: 1024 lock engine: pthread robust mutexes thunder lock: disabled (you can enable it with --thunder-lock) uwsgi socket 0 bound to TCP address 0.0.0.0:5002 fd 3 Python version: 2.7.3 (default, Sep 26 2013, 20:13:52)  [GCC 4.6.3] Python main interpreter initialized at 0x23632b0 python threads support enabled your server socket listen backlog is limited to 100 connections your mercy for graceful operations on workers is 60 seconds mapped 202864 bytes (198 KB) for 1 cores
    *** Operational MODE: single process *** WSGI app 0 (mountpoint='') ready in 1 seconds on interpreter 0x23632b0 pid: 30636 (default app)
    *** uWSGI is running in multiple interpreter mode ***

Veja o que o uwsgi diz sobre o pedido de downlaod

[pid: 30643|app: 0|req: 763/763] 33.33.33.33 () {56 vars in 2982 bytes} [Wed Dec 10 15:09:59 2014] GET /download/test.xlsx => generated 5564 bytes in 392 msecs via sendfile() (HTTP/1.1 200) 7 headers in 510 bytes (0 switches on core 0)

    
por user299709 10.12.2014 / 09:30

0 respostas