Beispiel #1
0
 public function run()
 {
     $lockFile = $this->getLockFile();
     try {
         $this->checkMaxRuntime($lockFile);
     } catch (Exception $e) {
         $this->log('ERROR: ' . $e->getMessage());
         return;
     }
     if (!$this->shouldRun()) {
         return;
     }
     $lockAcquired = false;
     try {
         $this->helper->acquireLock($lockFile);
         $lockAcquired = true;
         if (isset($this->config['closure'])) {
             $this->runFunction();
         } else {
             $this->runFile();
         }
     } catch (InfoException $e) {
         $this->log('INFO: ' . $e->getMessage());
     } catch (Exception $e) {
         $this->log('ERROR: ' . $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 ::acquireLock
  * @expectedException \Jobby\Exception
  */
 public function testAquireLockShouldFailOnSecondTry()
 {
     $this->helper->acquireLock($this->lockFile);
     $this->helper->acquireLock($this->lockFile);
 }