Пример #1
0
 /**
  * Locks your script by ensuring that the script is not already running
  * @throws ProcessLockerException
  */
 public function lock()
 {
     if ($this->isProcessAlreadyRunning()) {
         throw new ProcessLockerException("Process with pid: {$this->originalPid} is already running.");
     }
     $this->cleanup();
     // Store current process's id in the specified pid file location
     $currentPid = getmypid();
     $this->shell->file_put_contents($this->pidFileLocation, $currentPid);
 }