Пример #1
0
 /**
  * Registers suspension error and suspends cloud platform if the timeout is reached
  *
  * @param    string   $errorMessage  The error message
  */
 public function registerError($errorMessage)
 {
     if (!$this->firstErrorOccurred instanceof EnvironmentProperty) {
         $this->firstErrorOccurred = $this->initProp($this->firstErrorOccurredProp, time());
         $this->firstErrorOccurred->save();
     } elseif (empty($this->firstErrorOccurred->value)) {
         $this->firstErrorOccurred->value = time();
         $this->firstErrorOccurred->save();
     } elseif ($this->isSuspended()) {
         //If cloud platform is already suspended we don't keep collecting error messages
         return;
     } else {
         //Checks suspension timeout
         if (time() - $this->firstErrorOccurred->value > static::PLATFORM_SUSPEND_INTERVAL) {
             //The cloud platform should be suspended
             $this->suspend();
         }
     }
     if ($this->lastErrorMessage instanceof EnvironmentProperty) {
         $this->lastErrorMessage->value = $errorMessage;
     } else {
         $this->lastErrorMessage = $this->initProp($this->lastErrorMessageProp, $errorMessage);
     }
     $this->lastErrorMessage->save();
 }