From 29c72f52253075889cae297e260554cd6cbfda0c Mon Sep 17 00:00:00 2001 From: Tanvi840 <32007811+Tanvi840@users.noreply.github.com> Date: Tue, 30 Apr 2024 22:15:31 +0530 Subject: [PATCH] Bugfix: Updated expansions before calling expand() function for environment variables Bugfix: Variables defined in environment= in [program:x] section cannot be used in %(ENV_X)s expansions since expansions are updated after calling the expand function. --- supervisor/options.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/supervisor/options.py b/supervisor/options.py index 271735200..25cb256c8 100644 --- a/supervisor/options.py +++ b/supervisor/options.py @@ -657,14 +657,14 @@ def get(opt, default, **kwargs): section.nocleanup = boolean(get('nocleanup', 'false')) section.strip_ansi = boolean(get('strip_ansi', 'false')) - environ_str = get('environment', '') - environ_str = expand(environ_str, expansions, 'environment') - section.environment = dict_of_key_value_pairs(environ_str) - # extend expansions for global from [supervisord] environment definition for k, v in section.environment.items(): self.environ_expansions['ENV_%s' % k ] = v + environ_str = get('environment', '') + environ_str = expand(environ_str, expansions, 'environment') + section.environment = dict_of_key_value_pairs(environ_str) + # Process rpcinterface plugins before groups to allow custom events to # be registered. section.rpcinterface_factories = self.get_plugins( @@ -969,12 +969,12 @@ def get(section, opt, *args, **kwargs): expansions.update({'process_num': process_num, 'numprocs': numprocs}) expansions.update(self.environ_expansions) - environment = dict_of_key_value_pairs( - expand(environment_str, expansions, 'environment')) - # extend expansions for process from [program:x] environment definition for k, v in environment.items(): expansions['ENV_%s' % k] = v + + environment = dict_of_key_value_pairs( + expand(environment_str, expansions, 'environment')) directory = get(section, 'directory', None)