gpt4 book ai didi

python - uWSGI 服务器没有响应

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:24:02 56 4
gpt4 key购买 nike

我尝试使用 Nginx + uWSGI 运行 Django 应用程序但没有成功。经过几个小时的谷歌搜索和调试,我做了最简单的 uwsgi 配置,它必须能工作:

$ uwsgi --http 127.0.0.1:8000 --wsgi-file test.py

test.py在哪里

def application(env, start_response):
start_response('200 OK', [('Content-Type','text/html')])
return "Hello World"

问题是:事实并非如此。同一台机器上的 wget 调用挂起:

$ wget http://127.0.0.1:8000
--2013-04-28 12:43:36-- http://127.0.0.1:8000/
Connecting to 127.0.0.1:8000... connected.
HTTP request sent, awaiting response...

uWSGI 输出是静默的(初始信息除外):

*** Starting uWSGI 1.9.8 (32bit) on [Sun Apr 28 12:43:56 2013] ***
compiled with version: 4.4.5 on 28 April 2013 06:22:28
os: Linux-2.6.27-ovz-4 #1 SMP Mon Apr 27 00:26:17 MSD 2009
...

连接实际上已经建立,因为杀死 uWSGI 会中止 wget。

可能 uWSGI 对发生的错误不够详细,或者我一定是漏掉了什么。任何进一步查看的提示都将受到赞赏。

更新:

更多系统详细信息:Debian 6.0.7、Python 2.6.6。

完整的 uWSGI 登录开始:

$ uwsgi --http 127.0.0.1:8000 --wsgi-file test.py
*** Starting uWSGI 1.9.8 (32bit) on [Mon Apr 29 04:50:03 2013] ***
compiled with version: 4.4.5 on 28 April 2013 06:22:28
os: Linux-2.6.27-ovz-4 #1 SMP Mon Apr 27 00:26:17 MSD 2009
nodename: max.local
machine: i686
clock source: unix
detected number of CPU cores: 4
current working directory: /home/user/dir
detected binary path: /home/user/dir/env/ENV/bin/uwsgi
*** WARNING: you are running uWSGI without its master process manager ***
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
uWSGI http bound on 127.0.0.1:8000 fd 4
spawned uWSGI http 1 (pid: 19523)
uwsgi socket 0 bound to TCP address 127.0.0.1:57919 (port auto-assigned) fd 3
Python version: 2.6.6 (r266:84292, Dec 27 2010, 00:18:12) [GCC 4.4.5]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x80f6240
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 63944 bytes (62 KB) for 1 cores
*** Operational MODE: single process ***
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x80f6240 pid: 19522 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 19522, cores: 1)

并且不会打印任何其他内容。

最佳答案

对于那些也可能遇到此问题的人,这是我调查的最终结果:这个问题肯定与环境有关,而且很可能是 Linux 内核特定的。strace 实用程序显示 uWSGI 无法接收单个字节 - 这是内核级别。

我认为关键是

os: Linux-2.6.27-ovz-4

Linux 在虚拟环境中运行,2.6.27 不是 Debian 6.0.7 的默认内核版本。在 2.6.32-5 中一切正常。

我不知道这是旧内核的错误,还是 uWSGI 兼容性,或两者兼而有之。但更新内核会有所帮助。

关于python - uWSGI 服务器没有响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16265513/

56 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com