python - 为什么我看不到 mod_wsgi 的进程

标签 python django mod-wsgi

我有一个 wsgi 应用程序配置如下:

WSGIApplicationGroup %{GLOBAL}
WSGIDaemonProcess myapp user=myuser threads=10 maximum-requests=10000
WSGIScriptAlias / /usr/local/myapp/wsgi.py
WSGIProcessGroup myapp

我希望看到我的应用程序正在运行的进程...但是使用 ps auxpstree 我没有看到子进程:

init─┬─apache2─┬─apache2
     │         ├─2*[apache2───26*[{apache2}]]
     │         ├─apache2───14*[{apache2}]
     │         ├─apache2───12*[{apache2}]
     │         └─apache2───16*[{apache2}]

我的 wsgi 是否在守护进程模式下执行?如何检查 python 进程的运行状况?

我正在尝试调试我的 wsgi python 应用程序,当同时请求大量连接时(例如:来自单个网页的 30 个连续的 ajax 请求),该应用程序会挂起(有时会出现内存故障)。

最佳答案

为了完整起见,我对 Mikko Ohtamaa 的评论进行了扩展。

mod_wsgi 进程名称确实采用父进程的名称,例如: /usr/sbin/apache2 -k start 取决于发行版等

使用 display-name 选项允许我们设置不同的进程名称:

Defines a different name to show for the daemon process when using the ps command to list processes. If the value is %{GROUP} then the name will be (wsgi:group) where group is replaced with the name of the daemon process group.

Note that only as many characters of the supplied value can be displayed as were originally taken up by argv0 of the executing process. Anything in excess of this will be truncated.

This feature may not work as described on all platforms. Typically it also requires a ps program with BSD heritage. Thus on some versions of Solaris UNIX the /usr/bin/ps program doesn’t work, but /usr/ucb/ps does. Other programs which can display this value include htop.

Reference .

示例:

WSGIDaemonProcess myapp user=myuser threads=10 maximum-requests=10000 display-name=django-myapp
WSGIScriptAlias / /usr/local/myapp/wsgi.py
WSGIProcessGroup myapp

然后:

ps aux | grep django-myapp

关于python - 为什么我看不到 mod_wsgi 的进程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24692247/

相关文章:

linux - "make"构建了错误的 python 版本

python - 将控制台输出重定向到 Python 字符串

django - 在 Django 中启用 sluggified URL

django - 加入不相关的模型并从查询集中删除重复项

python - mod_wsgi中python的时差

python - Windows上本地django开发如何配置apache和mod_wsgi

python - 'haslayer' 函数在 scapy-python 中不起作用

python - 写入后无法从 NamedTemporaryFile 中读取

python - 从 Revit 外部访问 Revit API

django - 检查模板中的网址是否匹配