diff --git a/frappyman.py b/frappyman.py index 9767f53..c06d8ea 100644 --- a/frappyman.py +++ b/frappyman.py @@ -23,7 +23,7 @@ import sys import os from glob import glob -from os.path import join, isdir, basename +from os.path import join, isdir, basename, expanduser from configparser import ConfigParser from servicemanager.base import ServiceManager, ServiceDown, UsageError @@ -49,22 +49,24 @@ class FrappyManager(ServiceManager): cfgpaths = [] cfgparser = ConfigParser() cfgparser.optionxform = str - cfgparser.read(self.env[ins]['FRAPPY_CONFIG_FILE']) - for cfgpath in cfgparser['confdir'].split(os.pathsep): - if cfgpath.endswith('SERV'): - cfgpaths.append(cfgpath[:-4] + service) + cfgfile = self.env[ins]['FRAPPY_CONFIG_FILE'].replace('', service) + cfgparser.read(cfgfile) + for cfgpath in cfgparser['FRAPPY']['confdir'].split(os.pathsep): + if cfgpath.endswith(''): + cfgpaths.append(cfgpath[:-6] + service) else: scfg = join(cfgpath, service) if isdir(scfg): cfgpaths.append(scfg) - cfgpaths.append(cfgpath) + cfgpaths.append(expanduser(cfgpath)) return cfgpaths def prepare_start(self, ins, service, cfg=''): start_dir, env = super().prepare_start(ins, service) - his = env.get('FRAPPY_HISTORY') - if his: - env['FRAPPY_HISTORY'] = his.replace('_SERVICE', '_' + service) + for key, value in env.items(): + if '' in value: + env[key] = value.replace('', service) + os.environ[key] = env[key] cfgpaths = self.config_dirs(ins, service) if cfgpaths: env['FRAPPY_CONFDIR'] = os.pathsep.join(cfgpaths)