Преглед изворни кода

Default stdout_capturefile and stderr_capturefile to NONE (instead of AUTO).

Chris McDonough пре 18 година
родитељ
комит
ef3a738612
4 измењених фајлова са 34 додато и 29 уклоњено
  1. 10 9
      README.txt
  2. 2 2
      src/supervisor/datatypes.py
  3. 21 16
      src/supervisor/options.py
  4. 1 2
      src/supervisor/tests/test_options.py

+ 10 - 9
README.txt

@@ -366,11 +366,11 @@ Configuration File '[program:x]' Section Settings
     stdout_logfile=AUTO
     stdout_logfile_maxbytes=50MB
     stdout_logfile_backups=10
-    stdout_capturefile=AUTO
+    stdout_capturefile=NONE
     stderr_logfile=AUTO
     stderr_logfile_maxbytes=50MB
     stderr_logfile_backups=10
-    stderr_capturefile=AUTO
+    stderr_capturefile=NONE
     environment=A=1,B=2
 
   '[program:foo]' -- the section header, required for each program.
@@ -479,14 +479,15 @@ Configuration File '[program:x]' Section Settings
   'stdout_logfile_backups' -- The number of stdout_logfile backups to
   keep around resulting from process stdout log file rotation.  Set
   this to 0 to indicate an unlimited number of backups.  Default: 10.
-  (New in 3.0, replaces "logfile_backups") 'stdout_capturefile' --
-  file written to when process is in "stdout capture mode" (see
-  "Capture Mode and Process Communication Events" later in this
-  document).  May be a file path, NONE, or AUTO.  The
+  (New in 3.0, replaces "logfile_backups")
+
+  'stdout_capturefile' -- file written to when process is in "stdout
+  capture mode" (see "Capture Mode and Process Communication Events"
+  later in this document).  May be a file path, NONE, or AUTO.  The
   stdout_capturefile value can contain Python string expressions that
   will evaluated against a dictionary that contains the keys
-  "process_num", "program_name" and "group_name".  Default: AUTO.
-  (New in 3.0, replaces 2.0's "logfile_backups")
+  "process_num", "program_name" and "group_name".  Default: NONE.
+  (New in 3.0)
 
   'stderr_logfile' -- Put process stderr output in this file unless
   redirect_stderr is true.  Accepts the same value types as
@@ -505,7 +506,7 @@ Configuration File '[program:x]' Section Settings
   capture mode" (see "Capture Mode and Process Communication Events"
   later in this document).  May contain the same Python string
   expressions as "stdout_capturefile". May be a file path, NONE, or
-  AUTO.  Default: AUTO.  (New in 3.0)
+  AUTO.  Default: NONE.  (New in 3.0)
 
   'environment' -- A list of key/value pairs in the form
   "KEY=val,KEY2=val2" that will be placed in the child process'

+ 2 - 2
src/supervisor/datatypes.py

@@ -81,9 +81,9 @@ class Automatic:
     pass
 
 def logfile_name(val):
-    if val in ('NONE', 'OFF'):
+    if val in ('NONE', 'OFF', None):
         return None
-    elif val in (None, 'AUTO'):
+    elif val in (Automatic, 'AUTO'):
         return Automatic
     else:
         return existing_dirpath(val)

+ 21 - 16
src/supervisor/options.py

@@ -702,7 +702,8 @@ class ServerOptions(Options):
                         '[%s] names unknown program %s' % (section, program))
                 homogeneous_exclude.append(program_section)
                 processes = self.processes_from_section(parser, program_section,
-                                                        group_name)
+                                                        group_name,
+                                                        ProcessConfig)
                 group_processes.extend(processes)
             groups.append(
                 ProcessGroupConfig(self, group_name, priority, group_processes)
@@ -715,7 +716,8 @@ class ServerOptions(Options):
                 continue
             program_name = section.split(':', 1)[1]
             priority = integer(get(section, 'priority', 999))
-            processes=self.processes_from_section(parser, section, program_name)
+            processes=self.processes_from_section(parser, section, program_name,
+                                                  ProcessConfig)
             groups.append(
                 ProcessGroupConfig(self, program_name, priority, processes)
                 )
@@ -744,7 +746,8 @@ class ServerOptions(Options):
                                      (pool_event_name, section))
                 pool_events.append(pool_event)
             processes=self.processes_from_section(parser, section, pool_name,
-                                                  listener=True)
+                                                  EventListenerConfig)
+
             groups.append(
                 EventListenerPoolConfig(self, pool_name, priority, processes,
                                         buffer_size, pool_events)
@@ -754,7 +757,9 @@ class ServerOptions(Options):
         return groups
 
     def processes_from_section(self, parser, section, group_name,
-                               listener=False):
+                               klass=None):
+        if klass is None:
+            klass = ProcessConfig
         programs = []
         get = parser.saneget
         program_name = section.split(':', 1)[1]
@@ -787,7 +792,7 @@ class ServerOptions(Options):
                     'numprocs > 1')
 
         for n in ('stdout_logfile', 'stderr_logfile'):
-            lf_name = logfile_name(get(section, n, None))
+            lf_name = logfile_name(get(section, n, Automatic))
             mb_key = '%s_maxbytes' % n
             maxbytes = byte_size(get(section, mb_key, '50MB'))
             if not maxbytes and lf_name is Automatic:
@@ -808,12 +813,17 @@ class ServerOptions(Options):
             logfiles = {}
 
             for k in ('stdout', 'stderr'):
-                for n in ('%s_logfile' % k, '%s_capturefile' % k):
-                    val = logfile_name(get(section, n, None))
-                    if isinstance(val, basestring):
-                        val = expand(val, expansions, n)
-                        
-                    logfiles[n] = val
+                n = '%s_logfile' % k
+                val = logfile_name(get(section, n, Automatic))
+                if isinstance(val, basestring):
+                    val = expand(val, expansions, n)
+                logfiles[n] = val
+
+                n = '%s_capturefile' % k
+                val = logfile_name(get(section, n, None))
+                if isinstance(val, basestring):
+                    val = expand(val, expansions, n)
+                logfiles[n] = val
 
                 bu_key = '%s_logfile_backups' % k
                 backups = integer(get(section, bu_key, 10))
@@ -823,11 +833,6 @@ class ServerOptions(Options):
                 maxbytes = byte_size(get(section, mb_key, '50MB'))
                 logfiles[mb_key] = maxbytes
 
-            if listener:
-                klass = EventListenerConfig
-            else:
-                klass = ProcessConfig
-
             pconfig = klass(
                 self,
                 name=expand(process_name, expansions, 'process_name'),

+ 1 - 2
src/supervisor/tests/test_options.py

@@ -338,7 +338,6 @@ class ServerOptionsTests(unittest.TestCase):
         startretries = 100
         user = root
         stdout_logfile = NONE
-        stdout_capturelogfile = NONE
         stdout_logfile_backups = 1
         stdout_logfile_maxbytes = 100MB
         stopsignal = KILL
@@ -364,7 +363,7 @@ class ServerOptionsTests(unittest.TestCase):
         self.assertEqual(pconfig.startretries, 100)
         self.assertEqual(pconfig.uid, 0)
         self.assertEqual(pconfig.stdout_logfile, None)
-        self.assertEqual(pconfig.stdout_capturefile, datatypes.Automatic)
+        self.assertEqual(pconfig.stdout_capturefile, None)
         self.assertEqual(pconfig.stdout_logfile_maxbytes, 104857600)
         self.assertEqual(pconfig.stopsignal, signal.SIGKILL)
         self.assertEqual(pconfig.stopwaitsecs, 100)