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?
Refer to http://supervisord.org/subprocess.html#subprocess-environment for more info. Environment Variables PORT=8000 command=uwsgi --ini uwsgi.
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.
Step 1 - Installation The supervisor service runs automatically after installation. You can check its status: sudo systemctl status supervisor.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With