init pre-daemonization issue

3 views
Skip to first unread message

Jeff Lindsay

unread,
Apr 18, 2012, 11:01:52 PM4/18/12
to ginkg...@googlegroups.com
Today we discovered that daemonizing apps that use ZeroMQ would lead to a bad file descriptor error. It turns out to be because we were creating zmq.Context() in the service __init__(), which was previously safe to do. Now, services are initialized before daemonizing. This is important because we need to initialize all services before starting so that we can collect all the Settings for help. This is a useful pattern that might be used for other things, so it would be a shame to give it up. 

Here is the issue for this:

My proposal is to change the runner so you pass Process a callable service factory. It will call the factory method to initialize the service tree and load all settings and help. Then it will keep that callable around, kill the service tree before daemonizing and then call the callable again in the new process to recreate the tree. 

**The result will be that all services will be initialized twice when you daemonize.**

It is convention to not do anything serious in init, and save any actual starting operations for do_start. However, it could be argued initializing everything twice on startup is not efficient. What are people's thoughts on this?

--
Jeff Lindsay
http://progrium.com
Reply all
Reply to author
Forward
0 new messages