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.