Improvements to rAdmin admin_shutdown and admin_restart. Both methods can now accept a parameter of noticetype = dialog in order to display a blue persistant dropdown instead of a short notice. Added an optional and configurable delay to the restart method, defaulting at 30 seconds as before. Both methods can also accept a noticetype = none dialog in order to act silently.
parent
63b6b9cdce
commit
ac2fcbe224
|
@ -213,9 +213,59 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||||
if (!m_app.SceneManager.TryGetScene(regionID, out rebootedScene))
|
if (!m_app.SceneManager.TryGetScene(regionID, out rebootedScene))
|
||||||
throw new Exception("region not found");
|
throw new Exception("region not found");
|
||||||
|
|
||||||
|
int timeout = 30000;
|
||||||
|
string message;
|
||||||
|
|
||||||
|
if (requestData.ContainsKey("restart")
|
||||||
|
&& ((string)requestData["restart"] == "delayed")
|
||||||
|
&& requestData.ContainsKey("milliseconds"))
|
||||||
|
{
|
||||||
|
timeout = Int32.Parse(requestData["milliseconds"].ToString());
|
||||||
|
|
||||||
|
if (timeout < 15000)
|
||||||
|
{
|
||||||
|
//It must be at least 15 seconds or we'll cancel the reboot request
|
||||||
|
timeout = 15000;
|
||||||
|
}
|
||||||
|
|
||||||
|
message
|
||||||
|
= "Region is restarting in " + ((int)(timeout / 1000)).ToString()
|
||||||
|
+ " second(s). Please save what you are doing and log out.";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
message = "Region is restarting in 30 second(s). Please save what you are doing and log out.";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (requestData.ContainsKey("noticetype")
|
||||||
|
&& ((string)requestData["noticetype"] == "dialog"))
|
||||||
|
{
|
||||||
|
m_app.SceneManager.ForEachScene(
|
||||||
|
delegate(Scene scene)
|
||||||
|
{
|
||||||
|
IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>();
|
||||||
|
if (dialogModule != null)
|
||||||
|
dialogModule.SendNotificationToUsersInRegion(UUID.Zero, "System", message);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!requestData.ContainsKey("noticetype")
|
||||||
|
|| ((string)requestData["noticetype"] != "none"))
|
||||||
|
{
|
||||||
|
m_app.SceneManager.ForEachScene(
|
||||||
|
delegate(Scene scene)
|
||||||
|
{
|
||||||
|
IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>();
|
||||||
|
if (dialogModule != null)
|
||||||
|
dialogModule.SendGeneralAlert(message);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
responseData["rebooting"] = true;
|
responseData["rebooting"] = true;
|
||||||
response.Value = responseData;
|
response.Value = responseData;
|
||||||
rebootedScene.Restart(30);
|
rebootedScene.Restart(timeout / 1000,false);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -419,13 +469,33 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||||
message = "Region is going down now.";
|
message = "Region is going down now.";
|
||||||
}
|
}
|
||||||
|
|
||||||
m_app.SceneManager.ForEachScene(
|
if (requestData.ContainsKey("noticetype")
|
||||||
|
&& ((string) requestData["noticetype"] == "dialog"))
|
||||||
|
{
|
||||||
|
m_app.SceneManager.ForEachScene(
|
||||||
delegate(Scene scene)
|
delegate(Scene scene)
|
||||||
|
{
|
||||||
|
IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>();
|
||||||
|
if (dialogModule != null)
|
||||||
|
dialogModule.SendNotificationToUsersInRegion(UUID.Zero, "System", message);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!requestData.ContainsKey("noticetype")
|
||||||
|
|| ((string)requestData["noticetype"] != "none"))
|
||||||
|
{
|
||||||
|
m_app.SceneManager.ForEachScene(
|
||||||
|
delegate(Scene scene)
|
||||||
{
|
{
|
||||||
IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>();
|
IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>();
|
||||||
if (dialogModule != null)
|
if (dialogModule != null)
|
||||||
dialogModule.SendGeneralAlert(message);
|
dialogModule.SendGeneralAlert(message);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Perform shutdown
|
// Perform shutdown
|
||||||
System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing
|
System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing
|
||||||
|
|
|
@ -872,6 +872,15 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="seconds">float indicating duration before restart.</param>
|
/// <param name="seconds">float indicating duration before restart.</param>
|
||||||
public virtual void Restart(float seconds)
|
public virtual void Restart(float seconds)
|
||||||
|
{
|
||||||
|
Restart(seconds, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Given float seconds, this will restart the region. showDialog will optionally alert the users.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="seconds">float indicating duration before restart.</param>
|
||||||
|
public virtual void Restart(float seconds, bool showDialog)
|
||||||
{
|
{
|
||||||
// notifications are done in 15 second increments
|
// notifications are done in 15 second increments
|
||||||
// so .. if the number of seconds is less then 15 seconds, it's not really a restart request
|
// so .. if the number of seconds is less then 15 seconds, it's not really a restart request
|
||||||
|
@ -893,8 +902,11 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
m_restartTimer.Elapsed += new ElapsedEventHandler(RestartTimer_Elapsed);
|
m_restartTimer.Elapsed += new ElapsedEventHandler(RestartTimer_Elapsed);
|
||||||
m_log.Info("[REGION]: Restarting Region in " + (seconds / 60) + " minutes");
|
m_log.Info("[REGION]: Restarting Region in " + (seconds / 60) + " minutes");
|
||||||
m_restartTimer.Start();
|
m_restartTimer.Start();
|
||||||
m_dialogModule.SendNotificationToUsersInRegion(
|
if (showDialog)
|
||||||
UUID.Random(), String.Empty, RegionInfo.RegionName + ": Restarting in 2 Minutes");
|
{
|
||||||
|
m_dialogModule.SendNotificationToUsersInRegion(
|
||||||
|
UUID.Random(), String.Empty, RegionInfo.RegionName + ": Restarting in " + (seconds / 60).ToString() + " Minutes");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue