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.

avinationmerge
CasperW 2009-11-26 15:17:44 +01:00
parent 63b6b9cdce
commit ac2fcbe224
2 changed files with 86 additions and 4 deletions

View File

@ -213,9 +213,59 @@ namespace OpenSim.ApplicationPlugins.RemoteController
if (!m_app.SceneManager.TryGetScene(regionID, out rebootedScene))
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;
response.Value = responseData;
rebootedScene.Restart(30);
rebootedScene.Restart(timeout / 1000,false);
}
catch (Exception e)
{
@ -419,6 +469,22 @@ namespace OpenSim.ApplicationPlugins.RemoteController
message = "Region is going down now.";
}
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)
{
@ -426,6 +492,10 @@ namespace OpenSim.ApplicationPlugins.RemoteController
if (dialogModule != null)
dialogModule.SendGeneralAlert(message);
});
}
}
// Perform shutdown
System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing

View File

@ -872,6 +872,15 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary>
/// <param name="seconds">float indicating duration before restart.</param>
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
// 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_log.Info("[REGION]: Restarting Region in " + (seconds / 60) + " minutes");
m_restartTimer.Start();
if (showDialog)
{
m_dialogModule.SendNotificationToUsersInRegion(
UUID.Random(), String.Empty, RegionInfo.RegionName + ": Restarting in 2 Minutes");
UUID.Random(), String.Empty, RegionInfo.RegionName + ": Restarting in " + (seconds / 60).ToString() + " Minutes");
}
}
}