|
@@ -103,6 +103,10 @@ class Options:
|
|
|
'/etc/supervisord.conf']
|
|
|
self.searchpaths = searchpaths
|
|
|
|
|
|
+ self.environ_expansions = {}
|
|
|
+ for k, v in os.environ.items():
|
|
|
+ self.environ_expansions['ENV_%s' % k] = v
|
|
|
+
|
|
|
def default_configfile(self):
|
|
|
"""Return the name of the found config file or print usage/exit."""
|
|
|
config = None
|
|
@@ -538,14 +542,14 @@ class ServerOptions(Options):
|
|
|
except (IOError, OSError):
|
|
|
raise ValueError("could not read config file %s" % fp)
|
|
|
parser = UnhosedConfigParser()
|
|
|
- parser.expansions = environ_expansions()
|
|
|
+ parser.expansions = self.environ_expansions
|
|
|
try:
|
|
|
parser.readfp(fp)
|
|
|
except ConfigParser.ParsingError, why:
|
|
|
raise ValueError(str(why))
|
|
|
|
|
|
expansions = {'here':self.here}
|
|
|
- expansions.update(environ_expansions())
|
|
|
+ expansions.update(self.environ_expansions)
|
|
|
if parser.has_section('include'):
|
|
|
if not parser.has_option('include', 'files'):
|
|
|
raise ValueError(".ini file has [include] section, but no "
|
|
@@ -889,7 +893,7 @@ class ServerOptions(Options):
|
|
|
for process_num in range(numprocs_start, numprocs + numprocs_start):
|
|
|
expansions = common_expansions
|
|
|
expansions.update({'process_num': process_num})
|
|
|
- expansions.update(environ_expansions())
|
|
|
+ expansions.update(self.environ_expansions)
|
|
|
|
|
|
environment = dict_of_key_value_pairs(
|
|
|
expand(environment_str, expansions, 'environment'))
|
|
@@ -1579,7 +1583,7 @@ class ClientOptions(Options):
|
|
|
except (IOError, OSError):
|
|
|
raise ValueError("could not read config file %s" % fp)
|
|
|
config = UnhosedConfigParser()
|
|
|
- config.expansions = environ_expansions()
|
|
|
+ config.expansions = self.environ_expansions
|
|
|
config.mysection = 'supervisorctl'
|
|
|
config.readfp(fp)
|
|
|
sections = config.sections()
|
|
@@ -2061,17 +2065,6 @@ def expand(s, expansions, name):
|
|
|
(s, name, str(ex))
|
|
|
)
|
|
|
|
|
|
-def environ_expansions():
|
|
|
- """Return dict of environment variables, suitable for use in string
|
|
|
- expansions.
|
|
|
-
|
|
|
- Every environment variable is prefixed by 'ENV_'.
|
|
|
- """
|
|
|
- x = {}
|
|
|
- for key, value in os.environ.items():
|
|
|
- x['ENV_%s' % key] = value
|
|
|
- return x
|
|
|
-
|
|
|
def make_namespec(group_name, process_name):
|
|
|
# we want to refer to the process by its "short name" (a process named
|
|
|
# process1 in the group process1 has a name "process1"). This is for
|