为什么主管找不到命令源
Why can't supervisor find command source
以下是我的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
这是我得到的错误:
INFO spawnerr: can't find command 'source'
bash 应该没有命令源吧。如果这是使用 sh
我怎么能强制它 运行 bash?
Supervisor 根本不会启动 shell,无论是 bash
还是 sh
-- 所以它可以'找不到 shell-内置命令。如果你需要一个,你必须自己开始一个。因此:
command=/bin/bash -c 'source "[=10=]" && exec "$@"' /opt/ros/indigo/setup.sh daphne -b 0.0.0.0 -p 8000 robot_configuration_interface.asgi:channel_layer
和
command=/bin/bash -c 'source "[=11=]" && exec "$@"' /opt/ros/indigo/setup.bash django-admin runworker
在这两种情况下,exec
的存在是为了告诉 shell 将内存中的自身替换为它正在执行的进程,而不是留下一个什么都不做的 shell 实例但等待该进程退出。
bash -c
之后的第一个参数放在[=16=]
,后面的放在</code>以后;因此,我们可以获取 <code>"[=18=]"
并执行 "$@"
来引用第一个这样的参数,然后是相同的后续参数。
来自 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.
因此,shell 操作(包括 &&
)同样不能期望在顶层可用。
我也遇到这个问题
而且我找到了更好的解决方案。
使用 source ~/.bash_profile
可能更好。
[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
如果主管创建的进程创建了子进程,也许可以参考:
http://supervisord.org/subprocess.html#pidproxy-program
以下是我的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
这是我得到的错误:
INFO spawnerr: can't find command 'source'
bash 应该没有命令源吧。如果这是使用 sh
我怎么能强制它 运行 bash?
Supervisor 根本不会启动 shell,无论是 bash
还是 sh
-- 所以它可以'找不到 shell-内置命令。如果你需要一个,你必须自己开始一个。因此:
command=/bin/bash -c 'source "[=10=]" && exec "$@"' /opt/ros/indigo/setup.sh daphne -b 0.0.0.0 -p 8000 robot_configuration_interface.asgi:channel_layer
和
command=/bin/bash -c 'source "[=11=]" && exec "$@"' /opt/ros/indigo/setup.bash django-admin runworker
在这两种情况下,exec
的存在是为了告诉 shell 将内存中的自身替换为它正在执行的进程,而不是留下一个什么都不做的 shell 实例但等待该进程退出。
bash -c
之后的第一个参数放在[=16=]
,后面的放在</code>以后;因此,我们可以获取 <code>"[=18=]"
并执行 "$@"
来引用第一个这样的参数,然后是相同的后续参数。
来自 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.
因此,shell 操作(包括 &&
)同样不能期望在顶层可用。
我也遇到这个问题
而且我找到了更好的解决方案。
使用 source ~/.bash_profile
可能更好。
[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
如果主管创建的进程创建了子进程,也许可以参考: http://supervisord.org/subprocess.html#pidproxy-program