Sfoglia il codice sorgente

Add SUPERVISOR_PROCESS_NAME to environment of children.

Chris McDonough 18 anni fa
parent
commit
78b46cc438
2 ha cambiato i file con 12 aggiunte e 0 eliminazioni
  1. 1 0
      src/supervisor/process.py
  2. 11 0
      src/supervisor/tests/test_process.py

+ 1 - 0
src/supervisor/process.py

@@ -256,6 +256,7 @@ class Subprocess:
                     env = os.environ.copy()
                     if self.config.environment is not None:
                         env.update(self.config.environment)
+                    env['SUPERVISOR_PROCESS_NAME'] = self.config.name
                     options.execve(filename, argv, env)
                 except OSError, why:
                     code = why[0]

+ 11 - 0
src/supervisor/tests/test_process.py

@@ -361,6 +361,17 @@ class SubprocessTests(unittest.TestCase):
         self.assertEqual(options.execv_args, ('/bin/cat', ['/bin/cat']) )
         self.assertEqual(options.execv_environment['_TEST_'], '1')
 
+    def test_spawn_as_child_environment_supervisor_process_name(self):
+        options = DummyOptions()
+        options.forkpid = 0
+        config = DummyPConfig(options, 'cat', '/bin/cat')
+        instance = self._makeOne(config)
+        result = instance.spawn()
+        self.assertEqual(result, None)
+        self.assertEqual(options.execv_args, ('/bin/cat', ['/bin/cat']) )
+        self.assertEqual(
+            options.execv_environment['SUPERVISOR_PROCESS_NAME'], 'cat')
+
     def test_spawn_as_child_stderr_redirected(self):
         options = DummyOptions()
         options.forkpid = 0