fix bug when restarting all frappy services

- return a copy of the modified env dict instread of modifiying in place
This commit is contained in:
2023-09-14 14:09:08 +02:00
parent 5b7a151222
commit 957a5f0b2c

View File

@ -83,21 +83,22 @@ class FrappyManager(ServiceManager):
def prepare_start(self, ins, service, cfg=''):
start_dir, env = super().prepare_start(ins, service)
env_update = {}
for key, value in env.items():
if '<SERV>' in value:
env[key] = value.replace('<SERV>', service)
env_update[key] = value.replace('<SERV>', service)
os.environ[key] = env[key]
cfgpaths = self.config_dirs(ins, service)
if cfgpaths:
env['FRAPPY_CONFDIR'] = os.pathsep.join(cfgpaths)
env_update['FRAPPY_CONFDIR'] = os.pathsep.join(cfgpaths)
# merge PYTHONPATH from servicemanager.cfg with the one from environment
pypathlist = []
for pypath in env.get('PYTHONPATH'), os.environ.get('PYTHONPATH'):
if pypath is not None:
pypathlist.extend(p for p in pypath.split(':') if p not in pypathlist)
if pypathlist:
env['PYTHONPATH'] = os.environ['PYTHONPATH'] = ':'.join(pypathlist)
return start_dir, env
env_update['PYTHONPATH'] = os.environ['PYTHONPATH'] = ':'.join(pypathlist)
return start_dir, dict(env, **env_update)
def do_start(self, ins, service=None, cfg='', restart=False, wait=False, logger=None):
if self.wildcard(ins) is not None: