安装
通过 pip 来安装
1 | pip install supervisor |
如果还没有 pip,运行下面的命令:
1 | curl -O http://python-distribute.org/distribute_setup.py |
在 Mac OS 下,还可能通过 homebrew 安装:
1 | brew install distribute |
将标准配置输出到某个路径下的命令是:
1 | echo_supervisord_conf > /etc/supervisord.conf |
运行 supervisor
supervisor 提供了2个运行程序:守护程序 supervisord
和客户端程序 supervisorctl
。守护程序在后台运行,管理其它进程;客户端程序用于操作supervisor。
启动守护进程:
1 | supervisord |
Mac OS 配置 launchd
添加文件 /Library/LaunchDaemons/com.agendaless.supervisord.plist
1 | "1.0\" encoding=\"UTF-8\"?> xml version=\ |
注册 plist1
launchctl load /Library/LaunchDaemons/com.agendaless.supervisord.plist
使用 supervisorctl
1 | supervisorctl -c /etc/supervisord.conf |
通过命令行直接运行:
1 | sudo supervisorctl start foo |
修改配置文件
1 | [unix_http_server] |
当更新配置文件后,重新启动守护进程:
1 | supervisord -c /etc/supervisord.conf |
常用程序
nginx
1 | [program:nginx] |
laravel queue
1 | [program:laravel-worker] |
可能遇到的问题:
问题:
* Starting Supervisor daemon manager...
Error: Another program is already listening on a port that one of our HTTP servers is configured to use. Shut this program down first before starting supervisord.
For help, use /usr/bin/supervisord -h
...fail!
解决办法:
删除 supervisor.sock