nginx/unit

Get worker ID from application process

Opened this issue · 2 comments

Hi,

In order to get consolidated stats from django-prometheus plugins with multiple workers, the prom module need to setup files on tmp dir.
By default, it save the tmp file suffixed by the pid of the worker process.
Documented here: documentation

In the documentation, we can see a snippet of code to use the worker id instead of the pid when uwsgi is used as server.

How can we have the same behaviour with unit ?

I can't see any env variable pushed with the application worker or any channel open with unit to retrieve this kind of information.

Do you have any hints ?

Thx.

ac000 commented

This kind of information is simply not provided.

The obvious thing (to me anyway) seems to be to simply give those files a name that you can then easily lookup in a directory and know that it is a file you are interested in. You could even put said files in their own directory... then all you do is read through any files in there...

Hi,

As far i can read (and understand), the plugin does not work like that. The best way to have no orphaned files is to create predictible file name for each worker.
And nginx unit does not give the information of the process name/index.

Regards.