Discussion:
[uWSGI] on worker exit handler
Ondrej Tuma
2018-08-22 12:34:49 UTC
Permalink
Hi there,

i try to create custom metrics for prometheus with official
python prometheus_client library. I use uwsgi with gevent and Flask,
with more workers.

So i need to handle, when worker shut down to call

prometheus_client.mark_process_dead(worker_pid)

But i can't found another solution that log_alarm which will check
message like:

Brutally killing worker 7 (pid: 22)...

Please, have you anybody some better solution, or way, how can i check,
that worker was kill. I try to use signal.signal handler but that not
work.

Thanks a lot.
--
Ondřej Tůma <***@zeropage.cz>
https://ipv6.mcbig.cz https://keybase.io/mcbig twitter: mcbig_cz
Ondrej Tuma
2018-08-23 11:16:19 UTC
Permalink
So, i try to:

signal.signal call directly after/before app, with and without
py-call-osafterfork and py-master-check-signals options - not work

signal.signal call in postfork function, with and
without py-call-osafterfork option - not work

I try to use alarms on log, but that not emits, neither when i try to
use example from documentation. I try to:
cmd: echo ...
cmd: curl ...
log:
- not work

Probably, that is the problem with gevent which i use.

I found some not-documented uwsgi.atexit, which work well!

It looks, that I solve the same problem as
https://github.com/unbit/uwsgi/issues/680 describe. So it could be
documented, because we need the PID of exited worker. For another
solution, i could need some other resources from worker. That is, why i
can't use hook-as-user-atexit.

The better could be atexit decorator, which is what i try to found
first.

Ondra

V Wed, 22 Aug 2018 14:34:49 +0200
Post by Ondrej Tuma
Hi there,
i try to create custom metrics for prometheus with official
python prometheus_client library. I use uwsgi with gevent and Flask,
with more workers.
So i need to handle, when worker shut down to call
prometheus_client.mark_process_dead(worker_pid)
But i can't found another solution that log_alarm which will check
Brutally killing worker 7 (pid: 22)...
Please, have you anybody some better solution, or way, how can i
check, that worker was kill. I try to use signal.signal handler but
that not work.
Thanks a lot.
--
Ondřej Tůma <***@zeropage.cz>
https://ipv6.mcbig.cz https://keybase.io/mcbig twitter: mcbig_cz
Continue reading on narkive:
Loading...