swoole常用的命令:
swoole停止服務: kill -9 $(ps aux|grep 'socket.php'|grep -v grep|awk '{print $2}')
開啟swoole服務壓人后台命令:
nohup php socket.php &
screen socket.php
swoole 腳本,如果服務停止,每一分鍾檢測自動啟動,配合cron定時任務運行下邊的腳本文件
#!/bin/bash
count=`ps -fe |grep "socket.php" | grep -v "grep" | wc -l`
echo $count
if [ $count -lt 1 ]; then
ps -eaf |grep "socket.php" | grep -v "grep"| awk '{print $2}'|xargs kill -9
sleep 2
ulimit -c unlimited
/usr/local/php7/bin/php /data/www/shoxot-api/mqtt/socket.php
echo "restart";
echo $(date +%Y-%m-%d_%H:%M:%S) >/data/script/log/restart.log
fi
這里有一個梗 ulimit -c unlimited 這里設置了unlimited 如果報錯了 會生成一個很大的core文件 ,並且很可能會重復的生成,導致硬盤直接占滿,正式環境最好去掉。
