コード例 #1
0
ファイル: LogTest.php プロジェクト: ackintosh/snidel
 /**
  * @test
  */
 public function writeWorkerLog()
 {
     $fp = fopen('php://temp', 'w');
     $this->log->setDestination($fp);
     $prop = new \ReflectionProperty('Ackintosh\\Snidel\\Log', 'ownerPid');
     $prop->setAccessible(true);
     $prop->setValue($this->log, 1);
     $prop = new \ReflectionProperty('Ackintosh\\Snidel\\Log', 'masterPid');
     $prop->setAccessible(true);
     $prop->setValue($this->log, 1);
     $this->log->info('test');
     rewind($fp);
     $this->assertStringMatchesFormat('%s(worker)%s', fgets($fp));
 }
コード例 #2
0
ファイル: Container.php プロジェクト: ackintosh/snidel
 /**
  * send signal to master process
  *
  * @return  void
  */
 public function sendSignalToMaster($sig = SIGTERM)
 {
     $this->log->info('----> sending signal to master. signal: ' . $sig);
     posix_kill($this->masterPid, $sig);
     $this->log->info('<---- sent signal.');
     $status = null;
     $this->pcntl->waitpid($this->masterPid, $status);
     $this->log->info('. status: ' . $status);
     $this->masterPid = null;
 }
コード例 #3
0
ファイル: Snidel.php プロジェクト: ackintosh/snidel
 public function __destruct()
 {
     if ($this->ownerPid === getmypid()) {
         if ($this->container->existsMaster()) {
             $this->log->info('shutdown master process.');
             $this->container->sendSignalToMaster();
         }
         unset($this->container);
     }
     if ($this->exceptionHasOccured) {
         $this->log->info('destruct processes are started.(exception has occured)');
         $this->log->info('--> deleting all shared memory.');
         $this->deleteAllData();
     } elseif ($this->ownerPid === getmypid() && !$this->joined && $this->receivedSignal === null) {
         $message = 'snidel will have to wait for the child process is completed. please use Snidel::wait()';
         $this->log->error($message);
         throw new \LogicException($message);
     }
 }