multiGroupOneForOne() public static method

public static multiGroupOneForOne ( $configs ) : Supervisor
return Supervisor
Ejemplo n.º 1
0
 public function testMultiGroupOneForOne_CreateKeeper()
 {
     Supervisor::multiGroupOneForOne(array(array('worker' => function () {
         exit;
     }), array('worker' => function () {
         exit;
     }), array('worker' => function () {
         exit;
     }, 'quantity' => 3, 'maxRestartTimes' => 3)));
 }
Ejemplo n.º 2
0
<?php

namespace Comos\Qpm\Supervision;

require \dirname(__DIR__) . '/bootstrap.inc.php';
use Comos\Qpm\Process\Process;
$file = $argv[1];
$file1 = $argv[2];
$configs = array(array('worker' => function () use($file) {
    \file_put_contents($file, 1, \FILE_APPEND);
    \usleep(1000 * 1000);
}), array('worker' => function () use($file1) {
    \file_put_contents($file1, '2', \FILE_APPEND);
    \usleep(1000 * 500);
}, 'quantity' => 2));
$supProcessCallback = function () use($configs) {
    $supervisor = Supervisor::multiGroupOneForOne($configs);
    $supervisor->start();
    $supervisor->registerSignalHandler();
};
$supProcess = Process::fork($supProcessCallback);
usleep(5000 * 1000);
$supProcess->terminate();
usleep(5000 * 1000);