public function suspend($reason, $forcefully = null, $user = null)
{
if (!in_array($this->status, array(SERVER_STATUS::RUNNING))) {
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) {
}
}
$reason = 'TODO';
//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->update(['status' => SERVER_STATUS::PENDING_SUSPEND, 'dateShutdownScheduled' => date("Y-m-d H:i:s", $forcefully ? time() : strtotime(Scalr::config('scalr.system.server_terminate_timeout')))]);
//$this->getServerHistory()->markAsTerminated($reason);
//$this->getServerHistory()->markAsSuspended($reason);
if (isset($this->farmId) && !$forcefully) {
Scalr::FireEvent($this->farmId, new BeforeHostTerminateEvent($this, true));
}
}