/// <summary> /// Handles the region restart abort command. /// </summary> /// <param name="scene">Scene.</param> /// <param name="args">Arguments.</param> void HandleRegionRestartAbort(IScene scene, string [] args) { IRestartModule restartModule = scene.RequestModuleInterface <IRestartModule> (); if (restartModule == null) { MainConsole.Instance.Error("[Restart]: Unable to locate restart module for this scene"); return; } string msg = "Restart aborted"; if (args.Length > 3) { msg = Util.CombineParams(args, 4); // assume everything else is the message } // are we aborting a scheduled restart? if (m_Alerts != null) { AbortRestart(msg); } else { MainConsole.Instance.Info("[Restart]: Abort ignored as no restart is in progress"); } }
/// <summary> /// Runs commands issued by the server console from the operator /// </summary> /// <param name="cmdparams">Additional arguments passed to the command</param> private void RunCommand(string[] cmdparams) { List <string> args = new List <string>(cmdparams); if (args.Count < 1) { return; } string command = args[0]; args.RemoveAt(0); cmdparams = args.ToArray(); switch (command) { case "reset": if (cmdparams.Length > 0) { if (cmdparams[0] == "region") { if (MainConsole.Instance.Prompt("Are you sure you want to reset the region?", "yes") != "yes") { return; } ResetRegion(); } } break; case "command-script": if (cmdparams.Length > 0) { m_OpenSimBase.RunCommandScript(cmdparams[0]); } break; case "restart-instance": //This kills the instance and restarts it IRestartModule restartModule = m_scene.RequestModuleInterface <IRestartModule>(); if (restartModule != null) { restartModule.RestartScene(); } break; } }
/// <summary> /// Handles the region restart command /// </summary> /// <param name="scene">Scene.</param> /// <param name="args">Arguments.</param> void HandleRegionRestart(IScene scene, string [] args) { bool allRegions = false; int seconds = 0; string message = " will restart in {0}"; string scnName = ""; if (scene != null) { scnName = scene.RegionInfo.RegionName; } // check if this for all scenes if ((args.Length > 1) && (args [1].ToLower() == "all")) { allRegions = true; var newargs = new List <string> (args); newargs.RemoveAt(1); args = newargs.ToArray(); scnName = "all regions"; } if (args.Length < 3) { if (MainConsole.Instance.Prompt("[Restart]: Do you wish to restart " + scnName + " immediately? (yes/no)", "no") != "yes") { MainConsole.Instance.Info("usage: region restart <time> [message]"); return; } } // do we have a time? if (args.Length > 2) { if (!int.TryParse(args [2], out seconds)) { MainConsole.Instance.Error("[Restart]: Unable to determine restart delay!"); return; } } // build message interval list List <int> times = new List <int> (); while (seconds > 0) { times.Add(seconds); if (seconds > 300) { seconds -= 120; } else if (seconds > 30) { seconds -= 30; } else { seconds -= 15; } } times.Add(0); // we should always have a 'zero' for the immediate request // have a message? if (args.Length > 3) { message = Util.CombineParams(args, 4); // assume everything else is the message } if (!allRegions) { // we have a specified region IRestartModule restartModule = scene.RequestModuleInterface <IRestartModule> (); if (restartModule == null) { MainConsole.Instance.Error("[Restart]: Unable to locate restart module for " + scnName); return; } restartModule.ScheduleRestart(UUID.Zero, scnName + message, times.ToArray(), true); } else { int offset = 0; // check for immediate restart if ((times.Count == 1) && (times [0] == 0)) { times [0] = 2; // delay initial restart by 2 seconds } foreach (IScene scn in MainConsole.Instance.ConsoleScenes) { for (int i = 0; i < times.Count; i++) { times [i] = times [i] + 5; // stagger each alert/restart by 5 seconds } scnName = scn.RegionInfo.RegionName; IRestartModule sceneRestart = scn.RequestModuleInterface <IRestartModule> (); if (sceneRestart == null) { MainConsole.Instance.Error("[Restart]: Unable to locate restart module for " + scnName); } else { sceneRestart.ScheduleRestart(UUID.Zero, scnName + message, times.ToArray(), true); offset++; } } } }