我有一个简单的应用程序,通过套接字提供数据,我需要坚持一些工人的一些用户。它与nginx config非常相似,并称之为粘性标题。但是nginx不知道我有多少工人。uWSGI知道并可以为用户服务特定的工人。但我不知道该怎么做。我所需要的全部是因为在多个工作线程中我有竞争条件问题
这是我的配置
[uwsgi]
module = wsgi
socket = backend.sock
processes = 16
master = true
enable-threads = true
single-interpreter = true
vacuum = true
die-on-term = true
thunder-lock = true
http-websockets = true
http-socket = :1234
chmod-socket = 660
gevent = 1024
gevent-early-monkey-patch = 1当我设置进程1时,所有进程都工作得很好,因为用户由同一个worker提供服务
发布于 2020-04-28 00:46:57
processes = 4
socket = $(PWD)/run/socket_http
socket = $(PWD)/run/socket_ws
map-socket = 0:1,2,3
map-socket = 1:4这将为web插座指定1个worker (第4个)。在nginx中,你终于可以这样做了:
location /socket.io/ {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
include uwsgi_params;
uwsgi_pass unix:/path/to/project/run/socket_ws;
}https://github.com/miguelgrinberg/Flask-SocketIO/issues/1195#issuecomment-619586400
https://stackoverflow.com/questions/61463062
复制相似问题