class Server{const PORT = 8888;public function port(){//netstat -anp 2/dev/null| grep 8888 |grep LISTEN |wc -l$shellCommand = netstat -anp 2/dev/null| grep . self::PORT . | grep LISTEN | wc -l...

class Server
{
const PORT = 8888;
public function port()
{
//netstat -anp 2>/dev/null| grep 8888 |grep LISTEN |wc -l
$shellCommand = 'netstat -anp 2>/dev/null| grep ' . self::PORT . "| grep LISTEN | wc -l";
$result = shell_exec($shellCommand);
if ($result != 1) {
//进程不存在,发送警报信息
echo 'At '.date('Y-m-d H:i:s') . ' service process is exit' . PHP_EOL;
} else {
echo 'At '.date('Y-m-d H:i:s') . ' service process is ok' . PHP_EOL;
}
}
}
Swoole\Timer::tick(1000, function (int $timer_id) {
(new Server)->port();
});
nohup /usr/bin/php ./Server.php > ~/test.log &
沃梦达教程
本文标题为:PHP+Swoole+Linux实现进程监控


猜你喜欢
- PHP仿tp实现mvc框架基本设计思路与实现方法分析 2022-10-18
- laravel实现按月或天或小时统计mysql数据的方法 2023-02-22
- 用nohup命令实现PHP的多进程 2023-09-02
- laravel通用化的CURD的实现 2023-03-17
- windows下9款一键快速搭建PHP本地运行环境的好工具(含php7.0环境) 2023-09-02
- PHP中PDO事务处理操作示例 2022-10-15
- PHP实现微信支付(jsapi支付)流程步骤详解 2022-10-09
- PHP简单实现二维数组的矩阵转置操作示例 2022-10-02
- php微信公众号开发之秒杀 2022-11-23
- Laravel balde模板文件中判断数据为空方法 2023-08-30