如何防止 Nginx 缓冲我的 uwsgi 应用程序的输出?对于我的彗星式应用程序,我使用的是长轮询,并且请求现在已缓冲。
我试图减小缓冲区的大小,但不允许将uwsgi_buffer_size和设为uwsgi_buffers0。也uwsgi_max_temp_file_size不起作用(尽管手册建议这样做)。
我怎样才能做到这一点?
我使用一个简单的 hello world 程序在 virtualenv 中的本地主机上运行了 nginx + uWSGI ,但是当我用一个简单的 Flask 应用程序替换 hello world 时出现此错误:
File "./wsgi_configuration_module.py", line 1, in <module>
from flask import Flask
ImportError: No module named flask
unable to load app mountpoint
Run Code Online (Sandbox Code Playgroud)
这是烧瓶应用程序(wsgi_configuration_module.py):
from flask import Flask
application = Flask(__name__)
@application.route("/")
def hello():
return "hello world"
if __name__ == "__main__":
application.run()
Run Code Online (Sandbox Code Playgroud)
uWSGI 配置(app_conf.xml):
<uwsgi>
<socket>127.0.0.1:9001</socket>
<chdir>/srv/www/labs/application</chdir>
<pythonpath>/srv/www</pythonpath>
<module>wsgi_configuration_module</module>
<callable>application</callable>
<no-site>true</no-site>
</uwsgi>
Run Code Online (Sandbox Code Playgroud)
nginx配置:
server {
listen 80;
server_name localhost;
access_log /srv/www/labs/logs/access.log;
error_log /srv/www/labs/logs/error.log;
location / { …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 LNP [Linux Nginx Python] 堆栈(这甚至是一件事吗?呵呵),但我遇到了一些困难。
很多关于这样做的博客文章和文档似乎都围绕着使用 Upstart 来管理 uWSGI 进程,这很好,但我注意到使用 init.d 脚本安装的包和/etc/uwsgi/{apps-enabled,apps-available}. 很明显,有更好的方法来做到这一点。
我有一些配置文件(如下),但我似乎无法启动 uwsgi 进程,运行 init.d 脚本什么也不做,报告成功但无提示失败(甚至没有日志)。
当我直接执行 uWSGI 时,我得到了这个:
% sudo uwsgi -i /etc/uwsgi/apps-enabled/site.ini
tmp = /
[uWSGI] getting INI configuration from /etc/uwsgi/apps-enabled/site.ini
Run Code Online (Sandbox Code Playgroud)
/usr/lib/uwsgi/plugins/python27_plugin.so
同样值得注意的是,当我尝试访问该站点时抛出的错误:
% cat logs/error.log
2012/01/08 23:26:12 [crit] 9167#0: *13 connect() to unix://tmp/site.sock failed (2: No such file or directory) while connecting to upstream, client: 60.241.99.33, server: mysite.com, request: "GET / HTTP/1.1", upstream: "uwsgi://unix://tmp/site.sock:", host: "mysite.com"
Run Code Online (Sandbox Code Playgroud)
uWSGI 配置
% cat /etc/uwsgi/apps-enabled/config.ini
[uwsgi] …Run Code Online (Sandbox Code Playgroud) 我想以www用户身份运行 uwsgi 服务器,但如果我写:
uwsgi --socket $SOCKET --chmod-socket 666 --pidfile $PIDFILE --daemonize $LOGFILE --chdir $CHDIR --pp $PYTHONPATH --module main --post-buffering 8192 --workers 1 --threads 10 --uid www --gid www
Run Code Online (Sandbox Code Playgroud)
发生套接字创建错误:
日志:
1 *** Starting uWSGI 1.4.1 (64bit) on [Mon Dec 10 22:15:23 2012] ***
2 compiled with version: 4.4.5 on 17 November 2012 23:31:14
3 os: Linux-2.6.32-5-amd64 #1 SMP Sun Sep 23 10:07:46 UTC 2012
4 nodename: autoblog
5 machine: x86_64
6 clock source: unix
7 pcre jit disabled …Run Code Online (Sandbox Code Playgroud) 我有一个在 uwsgi+nginx 上运行的 Flask Web 服务,它运行良好。
我有另一个在另一台服务器上运行的服务的开发版本。它也在 uwsgi+nginx 上运行。
我想要做的是,使用“真实”流量(POST 请求)测试开发服务器,我已经完成了验证开发服务器基本上运行良好的工作。只是想将两者与相同的实际流量进行比较。
我对此的基本想法如下:
(A) 是传统服务器 (B) 是测试服务器
用户请求
Nginx(A) 获取请求并将请求传递给 uwsgi(A) 进行处理。
Nginx(A) '复制' 请求并将其传递给 Nginx(B) 进行测试
uwsgi(A) 处理 Flask App(A) 中的请求并响应用户(通过 Nginx(A))
Nginx(B) 像传统服务器一样处理请求,但不响应用户(只是记录)
这有意义吗?我应该采取什么方法?
从昨天开始我就一直在纠结这个问题:无法从 uwsgi 加载配置
当我谷歌它时,什么也没有出现。我正在尝试使用非常简单的 uwsgi.ini 文件在 nginx 下运行 UWSGI。文件被正确指向。
谁能解释一下这个错误是什么,以及我如何诊断和修复它。如果有更多信息我可以发布以提供帮助,请询问。
问候,
詹姆士
我正在尝试设置一个厨师食谱,以使我的网站运行,并且一切似乎都运行良好,但uWSGI出现以下错误:
*** has_emperor mode detected (fd: 6) ***
[uWSGI] getting INI configuration from app-cms.ini
removed uwsgi instance app-cms.ini
Run Code Online (Sandbox Code Playgroud)
不再说这个:
open("/var/www/app-cms/logs/uwsgi.log"): Permission denied [utils.c line 246]
Run Code Online (Sandbox Code Playgroud)
现在正在创建该日志文件,其中包含以下内容:
*** Starting uWSGI 1.0.3-debian (64bit) on [Thu Feb 6 12:00:43 2014] ***
compiled with version: 4.6.3 on 17 July 2012 02:26:54
current working directory: /etc/uwsgi/apps-enabled
writing pidfile to /var/www/ediflo-cms/run/ediflo-cms.pid
detected binary path: /usr/bin/uwsgi-core
setgid() to 33
setuid() to 33
chdir(): Permission denied [uwsgi.c line 1723]
chdir(): Permission denied [uwsgi.c line 975]
Run Code Online (Sandbox Code Playgroud)
我不确定它试图去哪里 …
uwsgi 配置中的reload-on-as和evil-reload-on-as选项有什么区别?
我使用reload-on-as并且 uwsgi worker 仍然消耗无限内存并在任务完成时重新加载。当工作人员出于调试目的而消耗有限内存时,我需要杀死工作人员。最好的方法是什么?可能是限制作为选项?
为了尝试减少 Web 服务器上的内存使用量,我必须将 uwsgi 配置上的 max-requests 属性设置为 50。
这有什么缺点?
我们的站点上有 10 个工作人员,看起来工作人员每 20 分钟左右就会被回收一次,但至少到目前为止,它似乎达到了我们没有接近内存限制的预期效果。
我只是有点担心它可能会对用户产生副作用,但我不确定。有任何想法吗?
我已经使用 uwsgi 设置了一个 nginx Web 服务器来托管我的 Flask 应用程序。当我通过 LAN ip (192.168.1.x) 访问它时,我得到的网站很好,但是当我通过我的公共 IP 访问它时,我收到“404 Not Found nginx/1.14.0 (Ubuntu)”。为什么是这样?我该如何修复它?
/etc/nginx/nginx.conf
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers …Run Code Online (Sandbox Code Playgroud) uwsgi ×10
nginx ×7
python ×3
buffer ×1
chef ×1
debian ×1
permissions ×1
socket ×1
ubuntu ×1
virtualenv ×1