views:

34

answers:

1

I'm running a site by apache2.x with mod_wsgi 2.5, and python2.5. It is configured to run in multi-processes and each process only contains one thread.

When I read this post, I try to set the process name to PATH_INFO, but it doesn't work. My code is like:

import ctypes
libc = ctypes.CDLL('/lib/libc.so.6')
def application (environ, start_response):
   libc.prctl(15, environ.get('PATH_INFO', 'WSGI'), 0, 0, 0);
   # other codes
+1  A: 

If you are using mod_wsgi daemon mode, is there anything wrong with the display-name option to WSGIDaemonProcess. That option is precisely for changing the name of the process to a fixed value using setproctitle() or argv[0] assignment as believed works for specific platforms. See:

http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIDaemonProcess

Note that it only makes sense to do this for daemon mode processes and not the Apache server processes themselves. Thus why is only available for WSGIDaemonProcess directive. It only makes sense to set it once on process start as well and not dynamically based on request.

Graham Dumpleton
> It only makes sense to set it once on process start as well and not dynamically based on request.what I expect is to set process name dynamically based on request, the *PATH_INFO* in environ
lethe
That doesn't make sense though as PATH_INFO will change between requests and because the web server can be multithreaded different requests may want to set it to different values at the same time. Further, on systems where you don't have setproctitle(), the hack is to change the value of argv[0] array value. You can however only stuff in this as much as the original argv[0] held and nothing more. Thus if PATH_INFO is longer than that it will be truncated and so you loose the latter half of the path.
Graham Dumpleton
BTW, if you want some sort of real time status about what requests Apache is handling, then use mod_status. See 'http://httpd.apache.org/docs/2.2/mod/mod_status.html'. It will show you what URLs are being accessed.
Graham Dumpleton