Changing the title of a modwsgi process

4 views
Skip to first unread message

Daniele Varrazzo

unread,
Feb 4, 2012, 6:44:42 PM2/4/12
to modwsgi
Hello,

I've released setproctitle 1.1.4 beta 1. The library allows to change
the unix title of a process from Python, for easy identification in
the ps output and any other tool. The news is that it now works with
embedded Python too (formerly it required Py_Main to set a couple of
global variables).

I've tested it in mod_wsgi, and it seems working fine:

$ ps afx
[...]
1274 ? Ss 0:00 /usr/sbin/apache2 -k start
1277 ? S 0:00 \_ /usr/sbin/apache2 -k start
1279 ? Sl 0:00 \_ hello, wsgi
1280 ? Sl 0:00 \_ /usr/sbin/apache2 -k start
1281 ? Sl 0:00 \_ /usr/sbin/apache2 -k start

It would be great if you could test it with some less basic setup than
mine. If the library doesn't work (e.g. calling the setproctitle()
function doesn't produce the expected result), it may be interesting
to compile the module with the env variable SPT_DEBUG set: it will
produce some hopefully helpful debugging log on stderr (mostly at
import time, not when the function is called).

The source package can be downloaded from <http://code.google.com/p/py-
setproctitle/>, where a bug tracker is available too.

Any feedback would be appreciated, thanks.

-- Daniele

Graham Dumpleton

unread,
Feb 4, 2012, 6:58:15 PM2/4/12
to mod...@googlegroups.com
What does this offer over and above the existing display-name option
to WSGIDaemonProcess directive which does the same thing?

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

Graham

> --
> You received this message because you are subscribed to the Google Groups "modwsgi" group.
> To post to this group, send email to mod...@googlegroups.com.
> To unsubscribe from this group, send email to modwsgi+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/modwsgi?hl=en.
>

Daniele Varrazzo

unread,
Feb 4, 2012, 8:00:00 PM2/4/12
to modwsgi
On Feb 4, 11:58 pm, Graham Dumpleton <graham.dumple...@gmail.com>
wrote:
> What does this offer over and above the existing display-name option
> to WSGIDaemonProcess directive which does the same thing?
>
>  http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIDae...

Uhm, I didn't know about the directive option. The module is a generic
one that I've recently discovered wasn't working properly under
mod_wsgi.

Something extra it offers is the possibility to change the title in
the python code, and to change it more than once: we use it in a few
programs to display *what* they are doing. If I understand correctly,
the directive setting can only be a constant set at configuration
time.

setproctitle doesn't even have the argv0 limitation mentioned in the
directive docs: the process can happily clobber both the whole argv
and environ. The latter is relocated and I've tested it keeps on
working fine (e.g. modifying env, then forking etc). Clobbering
environ can be avoided by setting an env variable (in order to have /
proc/PID/environ untouched, requested by a munin user).

-- Daniele

Graham Dumpleton

unread,
Feb 4, 2012, 8:06:30 PM2/4/12
to mod...@googlegroups.com
On 5 February 2012 12:00, Daniele Varrazzo <daniele....@gmail.com> wrote:
> On Feb 4, 11:58 pm, Graham Dumpleton <graham.dumple...@gmail.com>
> wrote:
>> What does this offer over and above the existing display-name option
>> to WSGIDaemonProcess directive which does the same thing?
>>
>>  http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIDae...
>
> Uhm, I didn't know about the directive option. The module is a generic
> one that I've recently discovered wasn't working properly under
> mod_wsgi.
>
> Something extra it offers is the possibility to change the title in
> the python code, and to change it more than once: we use it in a few
> programs to display *what* they are doing. If I understand correctly,
> the directive setting can only be a constant set at configuration
> time.

Yes, can only be set once. That value though can be automatically
derived from the daemon process group name by using %{GROUP}.

Am not sure of the value of dynamically changing it, plus that could
be problematic in a multithreaded application.

Graham

> setproctitle doesn't even have the argv0 limitation mentioned in the
> directive docs: the process can happily clobber both the whole argv
> and environ. The latter is relocated and I've tested it keeps on
> working fine (e.g. modifying env, then forking etc). Clobbering
> environ can be avoided by setting an env variable (in order to have /
> proc/PID/environ untouched, requested by a munin user).
>
> -- Daniele
>

Reply all
Reply to author
Forward
0 new messages