編程學習網 > PHP技術 > swoole > MixPHP V3 開發流程官方體驗||Swoole運行模式介紹
2021
10-11

MixPHP V3 開發流程官方體驗||Swoole運行模式介紹


MixPHP V3 發布后,由于本身支持超多的執行模式,swoole也支持多種模式,比如Swoole 多進程同步: 適合需要使用那些協程不支持的第三方庫的項目,和 Workerman 一致、Swoole 多進程協程: 適合專注 mysql + redis 需要超高 io 性能的項目、Swoole 單進程協程: 單進程協程就是 V2.2 版本那種 golang 風格協程,適合開發 websocket。真正做到效率與性能并存。本文以多進程為例帶大家了解怎么部署


使用 Swoole 多進程協程模式線上部署


Swoole、Workerman 你可以隨意選擇,這里我們采用 Swoole 舉例。


首先安裝 Swoole 擴展

修改 shell/server.sh 腳本中的絕對路徑和參數

這里我們選擇的 Swoole 多進程協程模式,因此入口文件為 bin/swoole.php,其他模式參考 composer.json


php=/usr/local/bin/php

file=/data/project/bin/swoole.php

cmd=start

numprocs=1

啟動管理


sh /data/project/shell/server.sh start

sh /data/project/shell/server.sh stop

sh /data/project/shell/server.sh restart

接下來將啟動命令加入 crontab 防止程序異常中斷


*/1 * * * * sh /data/project/shell/server.sh start > /tmp/server.sh.log 2>&1 &

當修改代碼時,使用 restart 讓代碼生效


sh /data/project/shell/server.sh restart

以上就是“MixPHP V3 開發流程官方體驗||Swoole運行模式介紹”的詳細內容,想要了解更多swoole教程歡迎持續關注編程學習網

掃碼二維碼 獲取免費視頻學習資料

Python編程學習

查 看2022高級編程視頻教程免費獲取