How do you export environment variables in the command executed by Supervisor? I first tried:
如何在Supervisor执行的命令中导出环境变量?我第一次尝试:
command="export SITE=domain1; python manage.py command"
but Supervisor reports "can't find command".
但是主管报告“找不到命令”。
So then I tried:
那么我试过了:
command=/bin/bash -c "export SITE=domain1; python manage.py command"
and the command runs, but this seems to interfere with the daemonization since when I stop the Supervisor daemon, all the other daemons it's running aren't stopped.
并且命令运行,但是这似乎干扰了守护进程,因为当我停止Supervisor守护进程时,它正在运行的所有其他守护进程都没有停止。
2 个解决方案
#1
67
To add a single environment variable, You can do something like this.
要添加单个环境变量,您可以执行以下操作。
[program:django]
environment=SITE=domain1
command = python manage.py command
But, if you want to export multiple environment variables, you need to separate them by comma.
但是,如果要导出多个环境变量,则需要用逗号分隔它们。
[program:django]
environment =
SITE=domain1,
DJANGO_SETTINGS_MODULE=foo.settings.local,
DB_USER=foo,
DB_PASS=bar
command = python manage.py command
#2
12
Just do it separately:
只需单独执行:
environment=SITE=domain1
command=python manage.py command
Refer to http://supervisord.org/subprocess.html#subprocess-environment for more info.
有关详细信息,请参阅http://supervisord.org/subprocess.html#subprocess-environment。
#1
67
To add a single environment variable, You can do something like this.
要添加单个环境变量,您可以执行以下操作。
[program:django]
environment=SITE=domain1
command = python manage.py command
But, if you want to export multiple environment variables, you need to separate them by comma.
但是,如果要导出多个环境变量,则需要用逗号分隔它们。
[program:django]
environment =
SITE=domain1,
DJANGO_SETTINGS_MODULE=foo.settings.local,
DB_USER=foo,
DB_PASS=bar
command = python manage.py command
#2
12
Just do it separately:
只需单独执行:
environment=SITE=domain1
command=python manage.py command
Refer to http://supervisord.org/subprocess.html#subprocess-environment for more info.
有关详细信息,请参阅http://supervisord.org/subprocess.html#subprocess-environment。