Gets terminate reason
public static getTerminateReason ( integer $reasonId ) : string | ||
$reasonId | integer | Reason id |
return | string |
/** * Marks server as to be terminated. * * @param int|array $reason The reason possibly with the format parameters. * @param bool $forcefully optional Method: forcefully (true) | gracefully (false) * @param User $user optional The user entity * @return bool */ public function terminate($reason, $forcefully = null, $user = null) { if (in_array($this->status, [Server::STATUS_PENDING_TERMINATE, Server::STATUS_TERMINATED])) { return false; } $forcefully = $forcefully === null ? true : (bool) $forcefully; $fnGetReason = function ($reasonId) { $args = func_get_args(); $args[0] = Server::getTerminateReason($reasonId); return [call_user_func_array('sprintf', $args), $reasonId]; }; list($reason, $reasonId) = is_array($reason) ? call_user_func_array($fnGetReason, $reason) : $fnGetReason($reason); $properties = $this->properties; if ($user instanceof User) { $properties[self::TERMINATED_BY_ID] = $user->getId(); $properties[self::TERMINATED_BY_EMAIL] = $user->getEmail(); } $properties[self::REBOOTING] = 0; $properties->save(); $this->update(['status' => Server::STATUS_PENDING_TERMINATE, 'shutdownScheduled' => new DateTime($forcefully ? 'now' : Scalr::config('scalr.system.server_terminate_timeout'))]); $this->getHistory()->markAsTerminated($reason, $reasonId); if (isset($this->farmId)) { $DBServer = $this->__getDBServer(); Scalr::FireEvent($this->farmId, new BeforeHostTerminateEvent($DBServer, false)); // If instance was terminated outside scalr, we need manually fire HostDown if ($reasonId == self::TERMINATE_REASON_CRASHED) { Scalr::FireEvent($this->farmId, new HostDownEvent($DBServer, false)); } } return true; }