Supervisor / supervisor

Supervisor process control system for Unix (supervisord)
http://supervisord.org
Other
8.54k stars 1.25k forks source link

[supervisord.environment] double escaping of % #1441

Open plopidou opened 3 years ago

plopidou commented 3 years ago

Hi,

Not sure if this is a bug or I am not setting things up correctly.

Imagine the following (snipped) /etc/supervisord.conf file:

[supervisord]
<snip>
environment                      = STATIC_VAR="foo",
                                   DYNAMIC_VAR="bar_%%s_%%s"

DYNAMIC_VAR contains two "%s" placeholders, supposed to be replaced at runtime in a way similar to this:

from django.conf import settings
print(settings.DYNAMIC_VAR % (
    'foo',
    'bar'
))

... thus resulting in bar_foo_bar.

Now when I declare DYNAMIC_VAR in /etc/supervisord.conf, supervisord cannot start, and complains:

Error: Format string <snip> for 'supervisord.environment' is badly formatted: not enough arguments for format string

Please note: . that environment variables with only one escaped %s work fine. . that moving the "double %s" variable to individual included files (for individual programs) seems to work fine. For example:

[program:worker1]
environment                      = STATIC_VAR="foo",
                                   DYNAMIC_VAR="bar_%%s_%%s",
                                   WORKER_1_VAR_1"toto",
                                   WORKER_1_VAR_2="toto_too"

I am (I think!) following the docs, but could there be an issue with the presence of multiple escaped % within the same environment variable, only when declared in the top-leve configuration files?

Many thanks!

edit: supervisor 3.4.0 on Centos7.9.

plopidou commented 3 years ago

Hi any news on this? It feels very weird that %% env variables work under individual [program] sections and yet not under the global [supervisord] section. Being able to use that under [supervisord] would help keeping some configuration files being more DRY.

Thanks!

plopidou commented 1 year ago

Hello,

Tick the appropriate box:

[ ] The example provided is full of bugs [ ] There is actually an issue, but we haven't had the time to look at it

Thank you :)