public static function getStateOfWorkers()
    {
        $offset = 0;

        $stat = [
            'idle' => 0,
            'busy' => 0,
            'alive' => 0,
            'shutdown' => 0,
            'preinit' => 0,
            'init' => 0,
            'reloading' => 0,
        ];
        $readed = 0;
        while (($buf = Daemon::$shm_wstate->read($readed, 1024)) !== false) {
            $buflen = mb_orig_strlen($buf);
            $readed += $buflen;
            for ($i = 0; $i < $buflen; ++$i) {
                $code = ord($buf[$i]);
                if ($code >= 100) {
                    // reloaded (shutdown)
                    $code -= 100;
                    if ($code !== Daemon::WSTATE_SHUTDOWN) {
                        ++$stat['alive'];
                        if (Daemon::$process instanceof Thread\Master) {
                            Daemon::$process->reloadWorker($offset + $i + 1);
                            ++$stat['reloading'];
                            continue;
                        }
                    }
                }
                if ($code === Daemon::WSTATE_IDLE) {
                    // idle
                    ++$stat['alive'];
                    ++$stat['idle'];
                } elseif ($code === Daemon::WSTATE_BUSY) {
                    // busy
                    ++$stat['alive'];
                    ++$stat['busy'];
                } elseif ($code === Daemon::WSTATE_SHUTDOWN) {
                    // shutdown
                    ++$stat['shutdown'];
                } elseif ($code === Daemon::WSTATE_PREINIT) {
                    // pre-init
                    ++$stat['alive'];
                    ++$stat['preinit'];
                    ++$stat['idle'];
                } elseif ($code === Daemon::WSTATE_INIT) { // init
                    ++$stat['alive'];
                    ++$stat['init'];
                    ++$stat['idle'];
                }
            }
        }
        return $stat;
    }
public static function getStateOfWorkers()
    {
        $offset = 0;

        $stat = [
            'idle' => 0,
            'busy' => 0,
            'alive' => 0,
            'shutdown' => 0,
            'preinit' => 0,
            'init' => 0,
            'reloading' => 0,
        ];
        $readed = 0;
        while (($buf = Daemon::$shm_wstate->read($readed, 1024)) !== false) {
            $buflen = mb_orig_strlen($buf);
            $readed += $buflen;
            for ($i = 0; $i < $buflen; ++$i) {
                $code = ord($buf[$i]);
                if ($code >= 100) {
                    // reloaded (shutdown)
                    $code -= 100;
                    if ($code !== Daemon::WSTATE_SHUTDOWN) {
                        ++$stat['alive'];
                        if (Daemon::$process instanceof Thread\Master) {
                            Daemon::$process->reloadWorker($offset + $i + 1);
                            ++$stat['reloading'];
                            continue;
                        }
                    }
                }
                if ($code === Daemon::WSTATE_IDLE) {
                    // idle
                    ++$stat['alive'];
                    ++$stat['idle'];
                } elseif ($code === Daemon::WSTATE_BUSY) {
                    // busy
                    ++$stat['alive'];
                    ++$stat['busy'];
                } elseif ($code === Daemon::WSTATE_SHUTDOWN) {
                    // shutdown
                    ++$stat['shutdown'];
                } elseif ($code === Daemon::WSTATE_PREINIT) {
                    // pre-init
                    ++$stat['alive'];
                    ++$stat['preinit'];
                    ++$stat['idle'];
                } elseif ($code === Daemon::WSTATE_INIT) { // init
                    ++$stat['alive'];
                    ++$stat['init'];
                    ++$stat['idle'];
                }
            }
        }
        return $stat;
    }
public static function getStateOfWorkers ( ) { $ offset = 0 ; $ stat = [ 'idle' => 0 , 'busy' => 0 , 'alive' => 0 , 'shutdown' => 0 , 'preinit' => 0 , 'init' => 0 , 'reloading' => 0 , ] ; $ readed = 0 ; while ( ( $ buf = Daemon :: $ shm_wstate -> read ( $ readed , 1024 ) ) !== false ) { $ buflen = mb_orig_strlen ( $ buf ) ; $ readed += $ buflen ; for ( $ i = 0 ; $ i < $ buflen ; ++ $ i ) { $ code = ord ( $ buf [ $ i ] ) ; if ( $ code >= 100 ) { // reloaded (shutdown) $ code -= 100 ; if ( $ code !== Daemon :: WSTATE_SHUTDOWN ) { ++ $ stat [ 'alive' ] ; if ( Daemon :: $ process instanceof Thread \ Master ) { Daemon :: $ process -> reloadWorker ( $ offset + $ i + 1 ) ; ++ $ stat [ 'reloading' ] ; continue ; } } } if ( $ code === Daemon :: WSTATE_IDLE ) { // idle ++ $ stat [ 'alive' ] ; ++ $ stat [ 'idle' ] ; } elseif ( $ code === Daemon :: WSTATE_BUSY ) { // busy ++ $ stat [ 'alive' ] ; ++ $ stat [ 'busy' ] ; } elseif ( $ code === Daemon :: WSTATE_SHUTDOWN ) { // shutdown ++ $ stat [ 'shutdown' ] ; } elseif ( $ code === Daemon :: WSTATE_PREINIT ) { // pre-init ++ $ stat [ 'alive' ] ; ++ $ stat [ 'preinit' ] ; ++ $ stat [ 'idle' ] ; } elseif ( $ code === Daemon :: WSTATE_INIT ) { // init ++ $ stat [ 'alive' ] ; ++ $ stat [ 'init' ] ; ++ $ stat [ 'idle' ] ; } } } return $ stat ; }
Get state of workers.
@return array - information.
Get state of workers .