Gets terminate reason
public static getTerminateReason ( integer $reasonId ) : string | ||
$reasonId | integer | Reason id |
return | string |
/** * Marks server as to be terminated. * * @param integer|array $reason The reason possibly with the format parameters. * @param bool $forcefully optional Method: forcefully (true) | gracefully (false) * @param Scalr_Account_User|int $user optional The user object or its unique identifier */ public function terminate($reason, $forcefully = null, $user = null) { if (in_array($this->status, array(SERVER_STATUS::PENDING_TERMINATE, SERVER_STATUS::TERMINATED))) { return; } $forcefully = $forcefully === null ? true : (bool) $forcefully; //Ensures handling identifier of the user instead of the object if ($user !== null && !$user instanceof \Scalr_Account_User) { try { $user = Scalr_Account_User::init()->loadById(intval($user)); } catch (\Exception $e) { } } $fnGetReason = function ($reasonId) { $args = func_get_args(); $args[0] = DBServer::getTerminateReason($reasonId); return [call_user_func_array('sprintf', $args), $reasonId]; }; list($reason, $reasonId) = is_array($reason) ? call_user_func_array($fnGetReason, $reason) : $fnGetReason($reason); //Set who does terminate the server if ($user instanceof \Scalr_Account_User) { $this->SetProperties(array(\SERVER_PROPERTIES::TERMINATED_BY_ID => $user->id, \SERVER_PROPERTIES::TERMINATED_BY_EMAIL => $user->getEmail())); } $this->SetProperties([SERVER_PROPERTIES::REBOOTING => 0]); $this->update(['status' => SERVER_STATUS::PENDING_TERMINATE, 'dateShutdownScheduled' => date("Y-m-d H:i:s", $forcefully ? time() : strtotime(Scalr::config('scalr.system.server_terminate_timeout')))]); $this->getServerHistory()->markAsTerminated($reason, $reasonId); if (isset($this->farmId)) { Scalr::FireEvent($this->farmId, new BeforeHostTerminateEvent($this, false)); // If instance was terminated outside scalr, we need manually fire HostDown if ($reasonId == self::TERMINATE_REASON_CRASHED) { Scalr::FireEvent($this->farmId, new HostDownEvent($this, false)); } } }