/** * */ 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); } } }
/** * @covers ::releaseLock * @expectedException \Jobby\Exception */ public function testReleaseNonExistin() { $this->helper->releaseLock($this->lockFile); }
/** * @covers Jobby\Helper::releaseLock */ public function testReleaseNonExistin() { $lockFile = $this->tmpDir . "/test.lock"; $this->setExpectedException("Jobby\\Exception"); $this->helper->releaseLock($lockFile); }