K
K
Kolya Vantukh2020-07-14 16:57:34
linux
Kolya Vantukh, 2020-07-14 16:57:34

How to get env variable in supervisor?

config file supervisord.conflooks like this

[supervisord]
nodaemon=true
environment=SITE_PATH="/home/admin/web/site.loc/public_html"
[supervisorctl]
[inet_http_server]
port = 127.0.0.1:9001
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[include]
files = supervisord.d/*.conf

You need to get the SITE_PATH variable in the workers
[program:site-develop-worker]
process_name=%(program_name)s_%(process_num)02d
command=php %(SITE_PATH)s/system/console.php pheanstalk:start --queue=develop
autostart=true
autorestart=true
user=admin
numprocs=2
redirect_stderr=true
stdout_logfile=%(SITE_PATH)s/system/storage/logs/worker.log

In this scenario, it gives an error
Error: Format string '%(SITE_PATH)s/system/storage/logs/worker.log' for 'program:site-develop-worker.stdout_logfile' contains names ('SITE_PATH') which cannot be expanded. Available names: ENV_GPG_KEYS, ENV_HOME, ENV_HOSTNAME, ENV_PATH, ENV_PGID, ENV_PHALCON_VERSION, ENV_PHPIZE_DEPS, ENV_PHP_ASC_URL, ENV_PHP_CFLAGS, ENV_PHP_CPPFLAGS, ENV_PHP_INI_DIR, ENV_PHP_LDFLAGS, ENV_PHP_MD5, ENV_PHP_SHA256, ENV_PHP_URL, ENV_PHP_VERSION, ENV_PUID, group_name, here, host_node_name, process_num, program_name in section 'program:site-develop-worker' (file: '/etc/supervisord.d/site-develop-worker.conf')

What am I doing wrong? variable
environment=SITE_PATH="/home/admin/web/site.loc/public_html"
seems to be installed in the right place. Or maybe there are some other ways to set the settings for all the workers? (for example, the path to the site), so as not to drive in the paths directly, since the workers are under the git

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Valdemar Smorman, 2020-07-14
@smorman

Is supervisord.conf the whole file, or just a selection?
And then it will be richer in the options.
[inet_http_server]
port = 127.0.0.1:9001
better like this:
[inet_http_server] ; inet (TCP) server disabled by default
port=*:9001 ; (ip_address:port specifier, *:port for all iface)
Section:
[include]
files = supervisord.d/*.conf
I do it differently:
[include]
;files = relative/directory/*.ini
files = /etc/ supervisor/conf.d/*.conf
ABSOLUTE path to prescribe.
Those. under the config itself directly for the process in a separate folder I do:
/etc/supervisor/conf.d
In the process config file in:
command=
it is necessary to prescribe the ABSOLUTE path (I wrote about this above).
Supervisor poorly understands variables, aliases, etc...
And it's better to remove user from the process config and write it in the main config file: supervisord.conf (it's there. Just uncomment it and write the right one):
[supervisord]
user= root (you are admin)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question