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
原文地址:https://www.cnblogs.com/cx558/p/9634505.html
时间: 2024-10-06 22:54:45