简体   繁体   中英

Why can't supervisor find command source

The following is my supervisor.conf .

[supervisord]
nodaemon=true

[program:daphne]
command=source "/opt/ros/indigo/setup.sh" && daphne -b 0.0.0.0 -p 8000 robot_configuration_interface.asgi:channel_layer

[program:worker]
environment=DJANGO_SETTINGS_MODULE="robot_configuration_interface.settings"
command= source "/opt/ros/indigo/setup.bash" && django-admin runworker

This is the error I get:

INFO spawnerr: can't find command 'source'

Shouldn't the bash have the command source. If this is using sh how can I force it to run bash?

Supervisor does not start a shell at all, either bash or sh -- so it's no surprise that it can't find shell-builtin commands. If you need one, you're obliged to start one yourself. Thus:

command=/bin/bash -c 'source "$0" && exec "$@"' /opt/ros/indigo/setup.sh daphne -b 0.0.0.0 -p 8000 robot_configuration_interface.asgi:channel_layer

and

command=/bin/bash -c 'source "$0" && exec "$@"' /opt/ros/indigo/setup.bash django-admin runworker

In both these cases, the exec is present to tell the shell to replace itself in-memory with the process it's executing rather than leaving a shell instance that does nothing but wait for that process to exit.

The first argument after bash -c is placed in $0 , and subsequent ones after that are placed in $1 and onward; thus, we can source "$0" and execute "$@" to refer to the first such argument and then those subsequent to same.


From the docs :

No shell is executed by supervisord when it runs a subprocess , so environment variables such as USER, PATH, HOME, SHELL, LOGNAME, etc. are not changed from their defaults or otherwise reassigned.

Thus, shell operations (including && ) similarly cannot be expected to be usable at top level.

I also encounter this problem.

And I found a better solution.

Using source ~/.bash_profile maybe better.

[program: dapi]
user=pyer
command=/bin/bash -c 'source ~/.bash_profile  && /usr/local/python3.6/bin/pipenv run python manage.py'
directory=/data/prd/tools/dapi
autostart=true
startretries=1
stopasgroup=true

If the process started by supervisor created subprocesses, maybe can ref: http://supervisord.org/subprocess.html#pidproxy-program

Try to verify if Nodejs is successfully installed by the simple command:

node -v

if not, install it and that's it. To install it in Debian based distributions:

sudo apt install nodejs

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM