releaseLock() public method

public releaseLock ( string $lockFile )
$lockFile string
Beispiel #1
0
 /**
  *
  */
 public function run()
 {
     $lockfile = $this->getLockFile();
     try {
         $this->checkMaxRuntime($lockfile);
     } catch (Exception $e) {
         $this->log("ERROR: " . $e->getMessage());
         $this->mail($e->getMessage());
         return;
     }
     if (!$this->shouldRun()) {
         return;
     }
     $lockAcquired = false;
     try {
         $this->helper->acquireLock($lockfile);
         $lockAcquired = true;
         if ($this->isFunction()) {
             $this->runFunction();
         } else {
             $this->runFile();
         }
     } catch (InfoException $e) {
         $this->log("INFO: " . $e->getMessage());
     } catch (Exception $e) {
         $this->log("ERROR: " . $e->getMessage());
         $this->mail($e->getMessage());
     }
     if ($lockAcquired) {
         $this->helper->releaseLock($lockfile);
         // remove log file if empty
         $logfile = $this->getLogfile();
         if (is_file($logfile) && filesize($logfile) <= 0) {
             unlink($logfile);
         }
     }
 }
Beispiel #2
0
 /**
  * @covers ::releaseLock
  * @expectedException \Jobby\Exception
  */
 public function testReleaseNonExistin()
 {
     $this->helper->releaseLock($this->lockFile);
 }
Beispiel #3
0
 /**
  * @covers Jobby\Helper::releaseLock
  */
 public function testReleaseNonExistin()
 {
     $lockFile = $this->tmpDir . "/test.lock";
     $this->setExpectedException("Jobby\\Exception");
     $this->helper->releaseLock($lockFile);
 }