Exemplo n.º 1
0
 /**
  * завершение работы
  */
 public function shutdown()
 {
     try {
         $this->onShutdown();
         static::log(getmypid() . ' is getting shutdown', Logger::L_DEBUG);
         static::log('Parent PID - ' . posix_getppid(), Logger::L_TRACE);
         parent::shutdown();
     } catch (\Exception $e) {
         exit(1);
     }
 }
Exemplo n.º 2
0
 /**
  * завершение работы мастерского процесса
  */
 public function shutdown($kill = FALSE)
 {
     try {
         $this->shutdown = TRUE;
         //останавливаем все дочерние процессы
         foreach ($this->child_collections as $name => $collection) {
             $collection->stop($kill);
             if (!$kill) {
                 //ждем, пока не остановятся все дочерние процессы
                 static::log('Waiting for all children of "' . $name . '" collection to shutdown...', Logger::L_INFO);
                 while ($collection->getNumber() > 0) {
                     static::log('"' . $name . '" collection: ' . $collection->getNumber() . ' of child threads remaining...', Logger::L_INFO);
                     $this->waitPid();
                     $this->sigwait();
                 }
             }
         }
         file_put_contents($this->pidfile, '');
         static::log('Getting shutdown...');
         $this->onShutdown();
         parent::shutdown();
     } catch (\Exception $e) {
         static::log($e->getMessage(), $e->getCode(), $e->getThrower());
         exit(1);
     }
 }