why I don't see processes of mod_wsgi

好久不见. 提交于 2019-12-12 19:16:38

问题


I have a wsgi application configured as follows:

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

I expected to see running processes for my app... but with ps aux or pstree I see no child processes:

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

Is my wsgi executing in daemon mode? How can I inspect the health of my python process?

I'm trying to debug my wsgi python application which hangs (sometimes with a memory fault) when a lot of connections are requested at the same time (say: 30 consecutive ajax requests from a single web page).


回答1:


For the sake of completeness I am expanding on the comment by Mikko Ohtamaa.

The mod_wsgi process name indeed takes the name of the parent process, something like eg. /usr/sbin/apache2 -k start depending on distros etc.

Using the display-name option allows us to set a different process 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.

Example:

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

Then:

ps aux | grep django-myapp


来源:https://stackoverflow.com/questions/24692247/why-i-dont-see-processes-of-mod-wsgi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!