Python 我如何在uwsgi后面运行的烧瓶上保持活力?

Python 我如何在uwsgi后面运行的烧瓶上保持活力?,python,uwsgi,Python,Uwsgi,我正在用烧瓶做蟒蛇3.6。它在uwsgi后面运行。我需要在此应用程序上启用keep alive,因此我在uwsgi命令上添加了-so keepalive参数,如下所示: uwsgi \ --uid uwsgi \ --master \ --http :8080 \ --enable-threads \ --so-keepalive \ --wsgi-file api/uwsgi.py 当检查请求-响应头时,“保持活动”不会出现。它只出现在请求头上。响应标头为: HTTP

我正在用烧瓶做蟒蛇3.6。它在uwsgi后面运行。我需要在此应用程序上启用keep alive,因此我在uwsgi命令上添加了-so keepalive参数,如下所示:

uwsgi \
  --uid uwsgi \
  --master \
  --http :8080 \
  --enable-threads \
  --so-keepalive \
  --wsgi-file api/uwsgi.py
当检查请求-响应头时,“保持活动”不会出现。它只出现在请求头上。响应标头为:

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 99
我使用curl测试连接:

curl -Iv http://localhost:9301/v2/health  --next http://localhost:9301/v2/health

*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 9301 (#0)
> HEAD /v2/health HTTP/1.1
> Host: localhost:9301
> User-Agent: curl/7.64.1
> Accept: */*
>
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
< Content-Type: application/json
Content-Type: application/json
< Content-Length: 5
Content-Length: 5

<
* Connection #0 to host localhost left intact
* Found bundle for host localhost: 0x7fb4db60b7d0 [can pipeline]
* Could pipeline, but not asked to!
* Connection 0 seems to be dead!
* Closing connection 0
* Hostname localhost was found in DNS cache
*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 9301 (#1)
> GET /v2/health HTTP/1.1
> Host: localhost:9301
> User-Agent: curl/7.64.1
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: application/json
< Content-Length: 5
<
"OK"
* Connection #1 to host localhost left intact
* Closing connection 1
您可以看到它创建了两个连接0和1。在我的服务器上似乎没有使用保持活动连接


我想知道我的应用程序是否启用了保持活动?如何启用它?

您应该使用http11\u套接字参数,例如

http11-socket = 0.0.0.0:8080
add-header = Connection: Keep-Alive
请参阅