如何在Supervisor服务中设置环境变量 [英] How to set environment variables in Supervisor service

查看:133
本文介绍了如何在Supervisor服务中设置环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Supervisor 执行的命令中如何导出环境变量?我第一次尝试:

How do you export environment variables in the command executed by Supervisor? I first tried:

command="export SITE=domain1; python manage.py command"

但主管报告找不到命令".

but Supervisor reports "can't find command".

然后我尝试了:

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.

推荐答案

要添加单个环境变量,您可以这样做.

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

这篇关于如何在Supervisor服务中设置环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆