标签 swoole 下的文章

class Server {
    const PORT = 8811;
    /**
     * 获取端口指定端口信息;如果在运行返回1;否则返回0;
     */
    public function port() {
        $shell  =  "netstat -anp 2>/dev/null | grep ". self::PORT . " | grep LISTEN | wc -l";

        $result = shell_exec($shell);
        if($result != 1) {
            // 发送报警服务 邮件 短信
            /// todo
            echo date("Ymd H:i:s")."error".PHP_EOL;
        } else {
            echo date("Ymd H:i:s")."succss".PHP_EOL;
        }
    }
}
/**
 * swoole毫秒定时器;每隔2秒运行一下脚本
 */
swoole_timer_tick(2000, function($timer_id) {
    (new Server())->port();
    echo "time-start".PHP_EOL;
});

- 阅读剩余部分 -