Example #1
0
 /**
  * Support one line arguments
  *
  * @param array $options
  */
 public function __construct($options = array())
 {
     if (is_string($options)) {
         $options = array('dir' => $options);
     }
     parent::__construct($options);
 }
Example #2
0
 /**
  * Run
  */
 public function run()
 {
     if ($this->running) {
         throw new \RuntimeException("Cluster already running");
     }
     $this->running = true;
     $that = $this;
     // Process middlewares
     foreach ($this->options['stacks'] as $stack) {
         $fn = Middleware::build($stack[0], $stack[1]);
         if (!$fn) {
             throw new \RuntimeException("Error middleware: " . $stack[0]);
         }
         $fn($this);
     }
     // Register tick
     $this->manager->on('tick', function () use($that) {
         $that->tickCheck();
     });
     // Run workers
     foreach ($this->workers as $worker) {
         $worker->run();
     }
 }