使用uWSGI / Nginx同时请求

时间:2018-02-02 21:54:44

标签: python docker nginx flask uwsgi

我的烧瓶服务器一次响应一个请求。是否有可能使其响应例如一次8个请求?

供参考,我的配置如下:

uWSGI

Database { open: false, filename: 'bin/data.db', mode: 65542 }

app.ini
对于nginx

[uwsgi] plugins = python3 chdir = /app module = app:app uid = nginx gid = nginx socket = /run/uwsgiApp.sock pidfile = /run/.pid processes = 4 threads = 2 enable-threads = true

nginx.conf

user nginx; worker_processes 8; pid /run/nginx.pid; error_log /dev/stdout info; events { worker_connections 20000; } worker_rlimit_nofile 40000; http { include mime.types; sendfile on; keepalive_timeout 65; gzip off; server { listen 80; server_name example.com; location / { try_files $uri @flaskApp; } location @flaskApp { include uwsgi_params; uwsgi_pass unix:/run/uwsgiApp.sock; } } } 用于Docker容器

entrypoint.sh

#!/bin/bash echo "Running app in production mode!" nginx && uwsgi --ini /app.ini --master

Dockerfile

FROM alpine:edge RUN cat /etc/apk/repositories RUN echo "http://nl.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories RUN echo "ipv6" >> /etc/modules RUN apk update # basic flask environment RUN apk add --no-cache bash git nginx uwsgi uwsgi-python3 \ && pip3 install --upgrade pip \ && pip3 install flask # For uWSGI RUN apk add linux-headers # expose web server ports EXPOSE 80 # application folder ENV APP_DIR /app # app dir RUN mkdir ${APP_DIR} \ && chown -R nginx:nginx ${APP_DIR} \ && chmod 777 /run/ -R \ && chmod 777 /root/ -R VOLUME ${APP_DIR} WORKDIR ${APP_DIR} # copy config files into filesystem COPY nginx.conf /etc/nginx/nginx.conf COPY app.ini /app.ini COPY entrypoint.sh /entrypoint.sh # execute start up script ENTRYPOINT ["/entrypoint.sh"] 适用于Flask

app.py

0 个答案:

没有答案