Supervisor安裝
# 安裝 epel 源,如果此前安裝過,此步驟跳過
yum install -y epel-release
# 安裝supervisor
yum install -y supervisor
# 設置supervisor開機自啟動
systemctl enable supervisord
# 啟動supervisord服務
systemctl start supervisord
# 查看supervisord服務狀態
systemctl status supervisord
配置hyper進程管理
supervisor安裝成功后會在/etc/目錄下生成supervisord.d文件夾及supervisord.conf配置文件
supervisord.conf 是總的配置文件,新增的配置可以在 supervisord.d 文件夾下創建一個hyperf.ini文件
新增的配置文件必須是以.ini結尾
# 新建一個應用并設置一個名稱,這里設置為 hyperf
[program:hyperf]
# 設置命令在指定的目錄內執行
directory=/var/www/hyperf/
# 這里為您要管理的項目的啟動命令
command=php ./bin/hyperf.php start
# 以哪個用戶來運行該進程,請確保該用戶有足夠的權限,否則啟動失敗
user=root
# supervisor 啟動時自動該應用
autostart=true
# 進程退出后自動重啟進程
autorestart=true
# 進程持續運行多久才認為是啟動成功
startsecs=1
# 重試次數
startretries=3
# stderr 日志輸出位置
stderr_logfile=/var/www/hyperf/runtime/stderr.log
# stdout 日志輸出位置
stdout_logfile=/var/www/hyperf/runtime/stdout.log
設置完成后記得重啟supervisord,使其生效
systemctl restart supervisord
Supervisord相關管理命令
# 啟動 hyperf 應用
supervisorctl start hyperf
# 重啟 hyperf 應用
supervisorctl restart hyperf
# 停止 hyperf 應用
supervisorctl stop hyperf
# 查看所有被管理項目運行狀態
supervisorctl status
# 重新加載配置文件
supervisorctl update
# 重新啟動所有程序
supervisorctl reload
轉自:https://www.kancloud.cn/wangking/hyperf/1992031