فهرست منبع

From Lawrence Rowe: allow RPC plugins to register new event types

Chris McDonough 14 سال پیش
والد
کامیت
fbbd700247
3فایلهای تغییر یافته به همراه12 افزوده شده و 9 حذف شده
  1. 3 0
      CHANGES.txt
  2. 2 4
      src/supervisor/events.py
  3. 7 5
      src/supervisor/options.py

+ 3 - 0
CHANGES.txt

@@ -1,4 +1,7 @@
 Next release
+
+  - Allow rpc interface plugins to register new events types.
+
   - Bug fix for FCGI sockets not getting cleaned up when the 'reload'
     command is issued from supervisorctl.  Also, the default behavior
     has changed for FCGI sockets.  They are new closed whenever the 

+ 2 - 4
src/supervisor/events.py

@@ -216,7 +216,5 @@ def getEventNameByType(requested):
         if typ is requested:
             return name
 
-
-        
-        
-
+def register(name, event):
+    EventTypes.__dict__[name] = event

+ 7 - 5
src/supervisor/options.py

@@ -558,17 +558,19 @@ class ServerOptions(Options):
         environ_str = get('environment', '')
         environ_str = expand(environ_str, {'here':self.here}, 'environment')
         section.environment = dict_of_key_value_pairs(environ_str)
+        # Process rpcinterface plugins before groups to allow custom events to
+        # be registered.
+        section.rpcinterface_factories = self.get_plugins(
+            parser,
+            'supervisor.rpcinterface_factory',
+            'rpcinterface:'
+            )
         section.process_group_configs = self.process_groups_from_parser(parser)
         for group in section.process_group_configs:
             for proc in group.process_configs:
                 env = section.environment.copy()
                 env.update(proc.environment)
                 proc.environment = env
-        section.rpcinterface_factories = self.get_plugins(
-            parser,
-            'supervisor.rpcinterface_factory',
-            'rpcinterface:'
-            )
         section.server_configs = self.server_configs_from_parser(parser)
         section.profile_options = None
         return section