14

我在 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'

有没有办法做到这一点?

4

1 回答 1

9

Supervisor 仅支持在有限数量的位置使用环境变量进行扩展,每个位置都记录在配置文档中。

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

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

在我的项目中,我们通常使用zc.buildout来使部署和开发环境设置可预测和可重复,并从模板生成主管配置。有一个专门的构建配方可以使这项任务更容易。

于 2012-07-17T07:58:55.253 回答