Supervisor / supervisor

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

Flatten environment variables from the program definition #1550

Closed vallsv closed 2 years ago

vallsv commented 2 years ago

Hi,

For a project i will have to handle a lot of env var, that i would like to put in the the program definition.

I was always struggling with the environment field, because of the quotes. But now i would like to see if there is some way to flatten the way it is written in the file.

Are you interest about such change?

Example from the documentation

[program:apache2]
command=/home/chrism/bin/httpd -c "ErrorLog /dev/stdout" -DFOREGROUND
user=chrism
environment=HOME="/home/chrism",USER="chrism"

Proposal

I have no idea what could be done. But here is some example.

[program:apache2]
command=/home/chrism/bin/httpd -c "ErrorLog /dev/stdout" -DFOREGROUND
user=chrism
environment=HOME="/home/chrism"
environment=USER="chrism"
[program:apache2]
command=/home/chrism/bin/httpd -c "ErrorLog /dev/stdout" -DFOREGROUND
user=chrism
environment
- HOME="/home/chrism"
- USER="chrism"

Tell me if you think it is something interesting and i can take a look deeper on what's doable.

mnaberez commented 2 years ago
$ cat supervisord.conf 
[supervisord]
nodaemon = true
loglevel = debug

[program:printenv]
command = /bin/bash -c 'env | sort | grep FOO_'
environment =
    FOO_1=BAR_1, 
    FOO_2=BAR_2,
    FOO_3=BAR_3
startsecs = 0
autorestart = false 

$ supervisord -v 
4.2.4

$ supervisord -c supervisord.conf 
2022-10-24 09:45:58,421 INFO supervisord started with pid 90000
2022-10-24 09:45:59,427 INFO spawned: 'printenv' with pid 90001
2022-10-24 09:45:59,438 DEBG 'printenv' stdout output:
FOO_1=BAR_1
FOO_2=BAR_2
FOO_3=BAR_3

2022-10-24 09:45:59,438 INFO success: printenv entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
2022-10-24 09:45:59,438 DEBG fd 7 closed, stopped monitoring <POutputDispatcher at 4533793984 for <Subprocess at 4533788896 with name printenv in state RUNNING> (stdout)>
2022-10-24 09:45:59,438 DEBG fd 9 closed, stopped monitoring <POutputDispatcher at 4533793936 for <Subprocess at 4533788896 with name printenv in state RUNNING> (stderr)>
2022-10-24 09:45:59,438 INFO exited: printenv (exit status 0; expected)
2022-10-24 09:45:59,439 DEBG received SIGCHLD indicating a child quit
vallsv commented 2 years ago

Sounds perfect. Thanks.

vallsv commented 2 years ago

BTW are you interested in an update of the documentation to talk about that?

mnaberez commented 2 years ago

BTW are you interested in an update of the documentation to talk about that?

Sure, feel free to submit a pull request. Thank you.