美文网首页
swoole服务挂掉,配合cron定时任务,自动启动

swoole服务挂掉,配合cron定时任务,自动启动

作者: 师娘哪里去了 | 来源:发表于2020-03-16 15:22 被阅读0次

swoole常用的命令:

swoole停止服务:

kill -9 $(ps aux|grep 'touge:swoole-server'|grep -v grep|awk '{print $2}')

开启swoole服务压人后台命令:

nohup /usr/bin/php /htdocs/school/artisan touge:swoole-server &

swoole 脚本,如果服务停止,每一分钟检测自动启动,配合cron定时任务运行下边的脚本文件

#!/bin/bash
count=`ps -fe |grep "touge:swoole-server" | grep -v "grep" | wc -l`

echo $count
if [ $count -lt 1 ]; then
ps -eaf |grep "touge:swoole-server" | grep -v "grep"| awk '{print $2}'|xargs kill -9
sleep 2
#ulimit -c unlimited
nohup /usr/bin/php /htdocs/school/artisan touge:swoole-server &
echo "restart";
echo $(date +%Y-%m-%d_%H:%M:%S) >/htdocs/school/restart.log
fi

这里有一个梗 ulimit -c unlimited 这里设置了unlimited 如果报错了 会生成一个很大的core文件 ,并且很可能会重复的生成,导致硬盘直接占满,正式环境最好去掉。

相关文章

网友评论

      本文标题:swoole服务挂掉,配合cron定时任务,自动启动

      本文链接:https://www.haomeiwen.com/subject/yuggehtx.html