如何在Supervisord的[supervisord]配置部分中使用环境变量?

时间:2012-07-16 19:42:38

标签: supervisord

我在Supervisord的程序部分使用环境变量,它们工作得很好:

[program:some_prog]
command=%(ENV_env_var_name)s/...

我无法弄清楚如何在[supervisord]部分做同样的事情。 我尝试使用带有和不带ENV_前缀的相同语法,但得到以下错误:

Traceback (most recent call last):
  File "/usr/local/bin/supervisord", line 9, in <module>
    load_entry_point('supervisor==3.0a12', 'console_scripts', 'supervisord')()
  File "/usr/local/lib/python2.7/dist-packages/supervisor-3.0a12-py2.7.egg/supervisor/supervisord.py", line 356, in main
    options.realize(args, doc=__doc__)
  File "/usr/local/lib/python2.7/dist-packages/supervisor-3.0a12-py2.7.egg/supervisor/options.py", line 419, in realize
    Options.realize(self, *arg, **kw)
  File "/usr/local/lib/python2.7/dist-packages/supervisor-3.0a12-py2.7.egg/supervisor/options.py", line 284, in realize
    self.process_config_file()
  File "/usr/local/lib/python2.7/dist-packages/supervisor-3.0a12-py2.7.egg/supervisor/options.py", line 478, in process_config_file
    Options.process_config_file(self, do_usage=do_usage)
  File "/usr/local/lib/python2.7/dist-packages/supervisor-3.0a12-py2.7.egg/supervisor/options.py", line 292, in process_config_file
    self.read_config(self.configfile)
  File "/usr/local/lib/python2.7/dist-packages/supervisor-3.0a12-py2.7.egg/supervisor/options.py", line 527, in read_config
    section.directory = existing_directory(directory)
  File "/usr/local/lib/python2.7/dist-packages/supervisor-3.0a12-py2.7.egg/supervisor/datatypes.py", line 336, in existing_directory
    nv = v % {'here':here}
KeyError: 'var_name'

有没有办法实现这个目标?

1 个答案:

答案 0 :(得分:9)

Supervisor仅支持在有限数量的位置扩展环境变量,每个位置都记录在configuration documentation中。

不幸的是,[supervisord] directory选项不是其中之一;它只支持%(here)变量,没有别的。

如果这对您来说是一个重要问题,您可以在supervisord issue tracker提交功能请求。

在我的项目中,我们通常使用zc.buildout来使部署和开发环境设置可预测且可重复,并从模板生成管理程序配置。有一个specialized buildout recipe可以让这项工作更轻松。