> Hi!
>
> I'm trying to implement workers warming up and have a little trouble.
> I have a fastrouter uwsgi instance and some workers which are should
> be warmed up before subcribing to fastrouter.
> I had created a post_fork hook which is calling an python application
> itself, it works perfectly. So all of my workers are warmed up, and
> now I need to subscribe them to the fastrouter (subscribing function
> is also implemented in the wsgi.py).
>
> I had no idea how to notify master that all the workers are warmed, so
> I created a temporary way to solve it: uwsgi queue, which stores
> workers' ids and when all of them are stored in queue, I'm sending a
> subcribe packet. Stupid way, I know, it's just a working prototype.
>
> And it working:
>
> [uwsgi-subscription for pid 16960] new pool: svartalf.local (hash key:
> 58247)
> [uwsgi-subscription for pid 16960] svartalf.local => new node:
> 127.0.0.1:8080
>
> But after a few requests, fastrouter removes that node:
>
> [uwsgi-subscription for pid 16960] svartalf.local => marking
> 127.0.0.1:8080 as failed (no announce received in 17 seconds)
>
> So, is there a simplier way to warm up workers and subscribe to
> fastrouter after it?
> I didn't find any way to do it, so I guess, I should send periodically
> a confirmation packet to fastrouter to say him that uwsgi instance is
> still alive.
> How can I do it?
>
> ## Configs and command lines:
>
> # uwsgi router command line: uwsgi --plugins fastrouter --fastrouter
> 127.0.0.1:8000 --fastrouter-subscription-server 127.0.0.1:7000
> --fastrouter-subscription-slot 80 --master
>
> # uwsgi app config and wsgi.py files here:
> https://gist.github.com/svartalf/8661828 (because they are too long)
> _______________________________________________
> uWSGI mailing list
> [email protected]
> http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi
>

Your setup would work if you constantly (at a 10 second rates for example)
you re-send the subscription packet.

Your implementation is really funny, but maybe you can super-simplify it
only using the master-fifo (you need the github version for
--start-unsubscribed):

uwsgi --master-fifo /tmp/fifo --subscribe 127.0.0.1:4040:foobar.it
--http-socket :9090 --start-unsubscribed --hook-accepting1-once
"writefifo:/tmp/fifo S"

the problem is that you need to start subscriptions when ALL of the
workers are ready to accept, and currently there is no hook in uWSGI for
it (hook-accepting1-once is run when the first worker is ready, otherwise
you have hook-accepting-once that is run every time a worker is ready)

Maybe the esiest thing for you is decorating subscribe() with @timer(10)
(and placing the checks there), or using a thread with a time.sleep()
sending it, but you will end with all workers subscribing constantly that
is overkill.

As the --start-unsubscribed is very uninvasive, i would invest on it, and
instead of subscribing in your code you simply send
'S' to the master fifo to re-enable them when you are ready. (your queue
usage is good for your use case, even if obviously it would be better to
have a uwsgi hook for "all-workers-accepting" event)



-- 
Roberto De Ioris
http://unbit.it
_______________________________________________
uWSGI mailing list
[email protected]
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi

Reply via email to