本文整理汇总了PHP中DBServer::getTerminateReason方法的典型用法代码示例。如果您正苦于以下问题:PHP DBServer::getTerminateReason方法的具体用法?PHP DBServer::getTerminateReason怎么用?PHP DBServer::getTerminateReason使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBServer
的用法示例。
在下文中一共展示了DBServer::getTerminateReason方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: terminate
/**
* 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));
}
}
}