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使用SMTP邮件服务器发送邮件示例 2022-11-16
- laravel model模型定义实现开启自动管理时间created_at,updated_at 2023-03-02
- thinkPHP3.2.2框架行为扩展及demo示例 2022-11-07
- PHP数据加密方式梳理介绍 2023-07-03
- TP5(thinkPHP5框架)基于bootstrap实现的单图上传插件用法示例 2023-01-19
- php中使用array_filter()函数过滤数组实例讲解 2023-05-19
- TP5 连接多个数据库及使用方法 2023-08-30
- PHP删除数组中指定值的元素常用方法实例分析【4种方法】 2022-11-12
- PHP实现创建一个RPC服务操作示例 2023-04-01
- PHP实现生成数据字典功能示例 2022-10-18