<commit_before><?php
/**
 * Created by PhpStorm.
 * User: shenzhe
 * Date: 2016/11/17
 * Time: 10:51
 */

namespace common;

use sdk\TcpClient;

class Timer
{
    public static function checkPing()
    {
        /**
         * @var \service\ServiceList
         * @desc 定时检测在线服务的状态
         */
        $service = LoadClass::getService('ServiceList');
        //@TODO 需要优化，如果机器比较多，检测会比较慢
        $allService = $service->fetchAll();
        if (!empty($allService)) {
            foreach ($allService as $item) {
                $rpc = new TcpClient($item->host, $item->port);
                try {
                    $result = $rpc->rawCall('ant-ping'); //发送ping包
                    if ('ant-pong' == $result) {
                        if(0 == $item->status) { //离线状态设置为在线状态
                            //@TODO 可以不单条更新，改为批量更新
                            $service->update(['status' => 1], ['id=' => $item->id]);
                        }
                        continue;<commit_msg>健康检查debug<commit_after><?php
/**
 * Created by PhpStorm.
 * User: shenzhe
 * Date: 2016/11/17
 * Time: 10:51
 */

namespace common;

use sdk\TcpClient;

class Timer
{
    public static function checkPing()
    {
        /**
         * @var \service\ServiceList
         * @desc 定时检测在线服务的状态
         */
        $service = LoadClass::getService('ServiceList');
        //@TODO 需要优化，如果机器比较多，检测会比较慢
        $allService = $service->fetchAll();
        if (!empty($allService)) {
            foreach ($allService as $item) {
                try {
                    $rpc = new TcpClient($item->ip, $item->port);
                    $result = $rpc->rawCall('ant-ping'); //发送ping包
                    if ('ant-pong' == $result) {
                        if(0 == $item->status) { //离线状态设置为在线状态
                            //@TODO 可以不单条更新，改为批量更新
                            $service->update(['status' => 1], ['id=' => $item->id]);
                        }
                        continue;
{'fraction_non_alphanumeric': 0.14969450101832993, 'fraction_numerical': 0.014256619144602852, 'mean_word_length': 1.4169741697416973, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2743949', 'n_tokens_mistral': 675, 'n_tokens_neox': 672, 'n_words': 113}