예제 #1
0
 public function testRecheck()
 {
     $testFile = "test.pid";
     $initialPid = 12345;
     $pid = new Pid($this->getPath($testFile), $initialPid);
     $this->assertEquals($initialPid, $pid->getPid());
     // check the pid set properly
     $finalPid = 67890;
     /** @var vfsStreamFile $file */
     $file = vfsStreamWrapper::getRoot()->getChild($testFile);
     $file->setContent("{$finalPid}");
     $this->assertEquals($initialPid, $pid->getPid());
     // check it doesn't update automatically
     $this->assertEquals($finalPid, $pid->getPid(true));
     // check a recheck pull the latest value
 }
예제 #2
0
 /**
  * gets the PID number from the PID file and caches it
  *
  * @param bool $skipCache
  * @return int
  */
 protected function getPid($skipCache = false)
 {
     $skipCache = (bool) $skipCache;
     if (!$skipCache && !empty($this->pid) && $this->pid instanceof Pid) {
         return $this->pid->getPid();
     }
     $pid = $this->pidFactory->create($this->poolPidFile);
     $pidNum = $pid->getPid();
     $this->pid = $pid;
     return $pidNum;
 }