## 安裝
~~~
# 安裝 epel 源,如果此前安裝過,此步驟跳過
yum install -y epel-release
yum install -y supervisor
systemctl enable supervisord # 開機自啟動
systemctl start supervisord # 啟動supervisord服務
# systemctl status supervisord # 查看supervisord服務狀態
~~~
## supervisord
> 運行`supervisor`時會啟動一個進程`supervisord`,它負責啟動所管理的進程,并將所管理的進程作為自己的子進程來啟動,而且可以在所管理的進程出現崩潰時自動重啟
~~~
systemctl restart supervisord
~~~
## supervisorctl (命令管理工具)
> 可以用來執行`start`、`stop`、`restart`等命令,來對這些子進程進行管理
```
# 啟動 hyperf 應用
supervisorctl start hyperf
# 重啟 hyperf 應用
supervisorctl restart hyperf
# 停止 hyperf 應用
supervisorctl stop hyperf
# 查看所有被管理項目運行狀態
supervisorctl status
# 重新加載配置文件
supervisorctl update
# 重新啟動所有程序
supervisorctl reload
```
## 網頁管理
> `supervisor`提供了基于`web`的控制,管理員可以通過在頁面上點點按鈕即可完成對進程的啟動、重啟以及查看狀態等操作,甚是方便
> vim /etc/supervisor.conf
```
[inet_http_server]
port=127.0.0.1:9001
;username=test
;password=123456
systemctl start supervisord
# sudo /usr/bin/supervisord -n -c /etc/supervisord.conf
```
> 打開瀏覽器,輸入地址`127.0.0.1:9001`