[prev in list] [next in list] [prev in thread] [next in thread] 

List:       uwsgi
Subject:    [uWSGI] question about uwsgi api and mules
From:       roberto () unbit ! it (Roberto De Ioris)
Date:       2014-03-13 5:30:27
Message-ID: 1dd888a00449a2cb31205891ab459990.squirrel () manage ! unbit ! it
[Download RAW message or body]


> I'm experimenting with the uwsgi API as described here:
> http://uwsgi-docs.readthedocs.org/en/latest/API.html
>
> I am using the uwsgi emperor, and the API is working well with one vassal,
> but what if I need to communicate between vassals?  Is the "mule" feature
> required for that?


not really, they are generally "too much" for simple messaging

>
> Also, what if I need to communicate state from the emperor to a vassal?
> For example, when the emperor scans mongodb (I am using the
> emperor_mongodb plugin) and begins listening on an on-demand socket for a
> new vassal, I want a special admin vassal to know about it.  I could poll
> the emperor's logs or set up emperor-stats and poll that.  But that's a
> little rough, and I know uwsgi has some great signaling features, so I am
> wondering if there is any way I can use signals for this type of thing.
> Or perhaps fire a signal or send a request to a mule on an emperor log
> entry matching a particular pattern?
>
>

the currently "blessed" way for such kind of operations is the "hooks
subsystem":

http://uwsgi-docs.readthedocs.org/en/latest/Hooks.html

unfortunately, there is no hook for "on-demand" event, but adding it would
be super-easy:

https://github.com/unbit/uwsgi/blob/master/core/emperor.c#L883

uwsgi_hooks_run(uwsgi.hook_as_emperor_on_demand, "as-emperor-on-demand", 0);


you could use it as a "signaling" system to wakeup the monitoring vassal
that can then get data from the stats server.

If you want to define new "action hooks" (the function to run on the hook)
you can get some idea from it:

https://github.com/unbit/uwsgi/blob/master/core/hooks.c#L489

Take in account we are in LTS mode, and 2.1 will open next week, so if
(eventually) your patches modify uwsgi.h they cannot be applied to 2.0


-- 
Roberto De Ioris
http://unbit.it

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic