Permalink
Browse files

Merge pull request #1163 from apollo13/fcgi-groups

Added support for fcgi-program in groups, fixes #148.
  • Loading branch information...
mnaberez committed Jan 7, 2019
2 parents 2a5fd12 + 27bdfd3 commit a0ee8f1026c929ae4d9fc84741924414e8008f49
Showing with 65 additions and 6 deletions.
  1. +12 −6 supervisor/options.py
  2. +53 −0 supervisor/tests/test_options.py
@@ -686,13 +686,19 @@ def get(section, opt, default, **kwargs):
group_processes = []
for program in programs:
program_section = "program:%s" % program
if not program_section in all_sections:
fcgi_section = "fcgi-program:%s" % program
if not program_section in all_sections and not fcgi_section in all_sections:
raise ValueError(
'[%s] names unknown program %s' % (section, program))
homogeneous_exclude.append(program_section)
processes = self.processes_from_section(parser, program_section,
group_name,
ProcessConfig)
'[%s] names unknown program or fcgi-program %s' % (section, program))
if program_section in all_sections and fcgi_section in all_sections:
raise ValueError(
'[%s] name %s is ambiguous (exists as program and fcgi-program)' %
(section, program))
section = program_section if program_section in all_sections else fcgi_section
homogeneous_exclude.append(section)
processes = self.processes_from_section(parser, section,
group_name, ProcessConfig)

group_processes.extend(processes)
groups.append(
ProcessGroupConfig(self, group_name, priority, group_processes)
@@ -2813,6 +2813,59 @@ def test_mixed_process_groups_from_parser2(self):
self.assertEqual(gconfig.priority, 5)
self.assertEqual(len(gconfig.process_configs), 4)

def test_mixed_process_groups_from_parser3(self):
text = lstrip("""\
[program:one]
command = /bin/cat
[fcgi-program:two]
command = /bin/cat
[program:many]
process_name = %(program_name)s_%(process_num)s
command = /bin/cat
numprocs = 2
priority = 1
[fcgi-program:more]
process_name = %(program_name)s_%(process_num)s
command = /bin/cat
numprocs = 2
priority = 1
[group:thegroup]
programs = one,two,many,more
priority = 5
""")
from supervisor.options import UnhosedConfigParser
config = UnhosedConfigParser()
config.read_string(text)
instance = self._makeOne()
gconfigs = instance.process_groups_from_parser(config)
self.assertEqual(len(gconfigs), 1)

gconfig = gconfigs[0]
self.assertEqual(gconfig.name, 'thegroup')
self.assertEqual(gconfig.priority, 5)
self.assertEqual(len(gconfig.process_configs), 6)

def test_ambiguous_process_in_heterogeneous_group(self):
text = lstrip("""\
[program:one]
command = /bin/cat
[fcgi-program:one]
command = /bin/cat
[group:thegroup]
programs = one""")
from supervisor.options import UnhosedConfigParser
config = UnhosedConfigParser()
config.read_string(text)
instance = self._makeOne()
self.assertRaises(ValueError, instance.process_groups_from_parser,
config)

def test_unknown_program_in_heterogeneous_group(self):
text = lstrip("""\
[program:one]

0 comments on commit a0ee8f1

Please sign in to comment.