Browse Source

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

Chris McDonough 14 years ago
parent
commit
fbbd700247
3 changed files with 12 additions and 9 deletions
  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
 Next release
+
+  - Allow rpc interface plugins to register new events types.
+
   - Bug fix for FCGI sockets not getting cleaned up when the 'reload'
   - Bug fix for FCGI sockets not getting cleaned up when the 'reload'
     command is issued from supervisorctl.  Also, the default behavior
     command is issued from supervisorctl.  Also, the default behavior
     has changed for FCGI sockets.  They are new closed whenever the 
     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:
         if typ is requested:
             return name
             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 = get('environment', '')
         environ_str = expand(environ_str, {'here':self.here}, 'environment')
         environ_str = expand(environ_str, {'here':self.here}, 'environment')
         section.environment = dict_of_key_value_pairs(environ_str)
         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)
         section.process_group_configs = self.process_groups_from_parser(parser)
         for group in section.process_group_configs:
         for group in section.process_group_configs:
             for proc in group.process_configs:
             for proc in group.process_configs:
                 env = section.environment.copy()
                 env = section.environment.copy()
                 env.update(proc.environment)
                 env.update(proc.environment)
                 proc.environment = env
                 proc.environment = env
-        section.rpcinterface_factories = self.get_plugins(
-            parser,
-            'supervisor.rpcinterface_factory',
-            'rpcinterface:'
-            )
         section.server_configs = self.server_configs_from_parser(parser)
         section.server_configs = self.server_configs_from_parser(parser)
         section.profile_options = None
         section.profile_options = None
         return section
         return section