Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use environment variables in Supervisord's [supervisord] config section?

Tags:

supervisord

I use environment variables in Supervisord's program section, and they work just fine:

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

I can't figure out though how to do the same in the [supervisord] section. I tried using the same syntax with and without the ENV_ prefix, but getting the following error:

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'

Is there a way to achieve that?

like image 591
syoavc Avatar asked Jul 16 '12 19:07

syoavc


People also ask

How do I set environment variables in supervisor?

Refer to http://supervisord.org/subprocess.html#subprocess-environment for more info. Environment Variables PORT=8000 command=uwsgi --ini uwsgi.

How do I start a Supervisord process?

To start supervisord, run $BINDIR/supervisord. The resulting process will daemonize itself and detach from the terminal. It keeps an operations log at $CWD/supervisor.

How can I check my supervisor status?

Step 1 - Installation The supervisor service runs automatically after installation. You can check its status: sudo systemctl status supervisor.


1 Answers

Supervisor only supports expansions with environment variables in a limited number of locations, each of which is documented in the configuration documentation.

Unfortunately, the [supervisord] directory option is not one of those; it only supports the %(here) variable, nothing else.

You could file a feature request for this in the supervisord issue tracker if this an important issue for you.

In my projects, we generally use zc.buildout to make deployment and development environment setup predictable and repeatable, and generate the supervisor configuration from a template. There is a specialized buildout recipe to make this task easier.

like image 87
Martijn Pieters Avatar answered Nov 11 '22 18:11

Martijn Pieters