我想使用supervisord运行我的Django项目的一些命令,但我不断收到以下错误:
supervisor.log:
2012-05-18 17:52:15,784 INFO spawnerr: can't find command 'source'
如果我删除“源”命令,日志显示相同的错误: can't find command 'python' 。
supervisord.conf摘录:
[program:django] directory=/home/mf/projects/djangopj/ command=beanstalkd -l 127.0.0.1 -p 11300 command=source /home/mf/virtualenvs/env/bin/activate command=python manage.py command1 command=python manage.py command2 user=mf autostart=true autorestart=true
我试图删除目录,并添加绝对path的命令,但我一直得到相同的错误。
我使用以下命令运行supervisord:
supervisord -c supervisord.conf -l supervisor.log
source命令仅在bash可用,而主pipe命令由sh运行。 我会build议使用脚本来执行你的命令:
/etc/supervisor/conf.d/my_app.conf
[program:my_app] command = bash /path/to/app/init.sh directory = /path/to/app/ user = ubuntu autostart=true autorestart=true
/path/to/app/init.sh
#!/bin/bash beanstalkd -l 127.0.0.1 -p 11300 source /home/mf/virtualenvs/env/bin/activate python manage.py command1 python manage.py command2
唯一的问题是,主pipe只能控制脚本,而不是命令。 如果你有一个情况,你希望主pipepipe理和保持一个特定的过程,我build议在你的bash init文件中使用exec ,这样主pipe将控制你的进程。 例如
/path/to/app/init.sh
#!/bin/bash exec beanstalkd -l 127.0.0.1 -p 11300
你可能会觉得这很有用: http : //sjsnyder.com/managing-virtualenv-apps-with-supervisor