Comos\Qpm\Supervision\Supervisor::oneForOne PHP Метод

oneForOne() публичный статический Метод

public static oneForOne ( $config ) : Supervisor
Результат Supervisor
    public static function oneForOne($config)
    {
        $configs = array(new Config($config));
        return self::_oneForOne($configs);
    }

Usage Example

Пример #1
0
 protected function _doTestStartAll($baseConfig, $useFactoryMethodToCreateKeeper = false)
 {
     $config = $baseConfig;
     $config['quantity'] = $quantity = 3;
     if (!$useFactoryMethodToCreateKeeper) {
         $keeper = new OneForOneKeeper(array(new Config($config)));
     } else {
         $keeper = \Comos\Qpm\Supervision\Supervisor::oneForOne($config)->getKeeper();
     }
     $keeper->startAll();
     $pids = array();
     for ($i = 0; $i < $quantity; $i++) {
         $status = 0;
         $pids[\pcntl_wait($status)] = true;
     }
     $currentPid = \posix_getpid();
     $r = \file_get_contents($this->_logFile);
     $lines = explode("\n", $r);
     $count = 0;
     foreach ($lines as $line) {
         if (trim($line)) {
             list($pid, $ppid) = explode(',', $line);
             $count++;
             $this->assertTrue($pids[$pid]);
             $this->assertEquals($currentPid, $ppid);
         }
     }
     $this->assertEquals($quantity, $count);
 }
All Usage Examples Of Comos\Qpm\Supervision\Supervisor::oneForOne