diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index c09252a971..1b4d1ea9f9 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs @@ -208,18 +208,25 @@ namespace OpenSim.ApplicationPlugins.RemoteController UUID regionID = new UUID((string) requestData["regionID"]); - responseData["accepted"] = true; - responseData["success"] = true; - response.Value = responseData; - Scene rebootedScene; + responseData["success"] = false; + responseData["accepted"] = true; if (!m_application.SceneManager.TryGetScene(regionID, out rebootedScene)) throw new Exception("region not found"); responseData["rebooting"] = true; + + IRestartModule restartModule = rebootedScene.RequestModuleInterface(); + if (restartModule != null) + { + List times = new List { 30, 15 }; + + restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), true); + responseData["success"] = true; + } response.Value = responseData; - rebootedScene.Restart(30); + } catch (Exception e) { diff --git a/OpenSim/Framework/IScene.cs b/OpenSim/Framework/IScene.cs index 6798b7be8a..1298f26a62 100644 --- a/OpenSim/Framework/IScene.cs +++ b/OpenSim/Framework/IScene.cs @@ -73,7 +73,7 @@ namespace OpenSim.Framework void AddNewClient(IClientAPI client); void RemoveClient(UUID agentID); - void Restart(int seconds); + void Restart(); //RegionInfo OtherRegionUp(RegionInfo thisRegion); string GetSimulatorVersion(); diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index 622fc0802d..ddae20f21c 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs @@ -231,7 +231,23 @@ namespace OpenSim.Region.CoreModules.World.Estate private void handleEstateRestartSimRequest(IClientAPI remoteClient, int timeInSeconds) { - m_scene.Restart(timeInSeconds); + IRestartModule restartModule = m_scene.RequestModuleInterface(); + if (restartModule != null) + { + List times = new List(); + while (timeInSeconds > 0) + { + times.Add(timeInSeconds); + if (timeInSeconds > 300) + timeInSeconds -= 120; + else if (timeInSeconds > 30) + timeInSeconds -= 30; + else + timeInSeconds -= 15; + } + + restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), true); + } } private void handleChangeEstateCovenantRequest(IClientAPI remoteClient, UUID estateCovenantID) diff --git a/OpenSim/Region/CoreModules/World/Region/RestartModule.cs b/OpenSim/Region/CoreModules/World/Region/RestartModule.cs new file mode 100644 index 0000000000..c65aa6a8bd --- /dev/null +++ b/OpenSim/Region/CoreModules/World/Region/RestartModule.cs @@ -0,0 +1,263 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Reflection; +using System.Timers; +using System.Threading; +using System.Collections.Generic; +using log4net; +using Nini.Config; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Framework.Console; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using Timer=System.Timers.Timer; +using Mono.Addins; + +namespace OpenSim.Region.CoreModules.World.Region +{ + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RestartModule")] + public class RestartModule : INonSharedRegionModule, IRestartModule + { + private static readonly ILog m_log = + LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + protected Scene m_Scene; + protected Timer m_CountdownTimer = null; + protected DateTime m_RestartBegin; + protected List m_Alerts; + protected string m_Message; + protected UUID m_Initiator; + protected bool m_Notice = false; + protected IDialogModule m_DialogModule = null; + + public void Initialise(IConfigSource config) + { + } + + public void AddRegion(Scene scene) + { + m_Scene = scene; + scene.RegisterModuleInterface(this); + MainConsole.Instance.Commands.AddCommand("RestartModule", + false, "region restart bluebox", + "region restart bluebox