From 8e1d3386561f263646c10c875aa00af4b3c9f815 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sun, 1 Jun 2008 01:01:16 +0000 Subject: * Refactor: Split opensim background server into a separate class --- .../LoadRegions/LoadRegionsPlugin.cs | 4 +- .../RemoteController/RemoteAdminPlugin.cs | 4 +- .../Rest/Regions/RestRegionPlugin.cs | 2 +- OpenSim/ApplicationPlugins/Rest/RestPlugin.cs | 6 +- OpenSim/Region/Application/Application.cs | 4 +- OpenSim/Region/Application/IApplicationPlugin.cs | 2 +- OpenSim/Region/Application/OpenSim.cs | 680 +++++++++++++++++++ OpenSim/Region/Application/OpenSimBackground.cs | 80 +++ OpenSim/Region/Application/OpenSimBase.cs | 702 ++++++++++++++++++++ OpenSim/Region/Application/OpenSimMain.cs | 729 --------------------- OpenSim/Region/Application/OpenSimMainConsole.cs | 679 ------------------- OpenSim/Tools/Export/OpenSimExport.cs | 2 +- ThirdParty/3Di/LoadBalancer/LoadBalancerPlugin.cs | 4 +- ThirdParty/3Di/RegionProxy/RegionProxyPlugin.cs | 2 +- 14 files changed, 1477 insertions(+), 1423 deletions(-) create mode 100644 OpenSim/Region/Application/OpenSim.cs create mode 100644 OpenSim/Region/Application/OpenSimBackground.cs create mode 100644 OpenSim/Region/Application/OpenSimBase.cs delete mode 100644 OpenSim/Region/Application/OpenSimMain.cs delete mode 100644 OpenSim/Region/Application/OpenSimMainConsole.cs diff --git a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs index dc4d1db..8dde28c 100644 --- a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs +++ b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs @@ -46,7 +46,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions #region IApplicationPlugin Members - public void Initialise(OpenSimMain openSim) + public void Initialise(OpenSimBase openSim) { m_log.Info("[LOADREGIONS]: Load Regions addin being initialised"); @@ -84,7 +84,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions #endregion - public void LoadRegionFromConfig(OpenSimMain openSim, ulong regionhandle) + public void LoadRegionFromConfig(OpenSimBase openSim, ulong regionhandle) { m_log.Info("[LOADREGIONS]: Load Regions addin being initialised"); diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index c436596..232fd09 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs @@ -50,11 +50,11 @@ namespace OpenSim.ApplicationPlugins.RemoteController { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private OpenSimMain m_app; + private OpenSimBase m_app; private BaseHttpServer m_httpd; private string requiredPassword = String.Empty; - public void Initialise(OpenSimMain openSim) + public void Initialise(OpenSimBase openSim) { try { diff --git a/OpenSim/ApplicationPlugins/Rest/Regions/RestRegionPlugin.cs b/OpenSim/ApplicationPlugins/Rest/Regions/RestRegionPlugin.cs index aeb91a9..9d68225 100644 --- a/OpenSim/ApplicationPlugins/Rest/Regions/RestRegionPlugin.cs +++ b/OpenSim/ApplicationPlugins/Rest/Regions/RestRegionPlugin.cs @@ -85,7 +85,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions /// Note that entries MUST be added to the active configuration files before /// the plugin can be enabled. /// - public override void Initialise(OpenSimMain openSim) + public override void Initialise(OpenSimBase openSim) { try { diff --git a/OpenSim/ApplicationPlugins/Rest/RestPlugin.cs b/OpenSim/ApplicationPlugins/Rest/RestPlugin.cs index ffabb2a..e4bd544 100644 --- a/OpenSim/ApplicationPlugins/Rest/RestPlugin.cs +++ b/OpenSim/ApplicationPlugins/Rest/RestPlugin.cs @@ -60,7 +60,7 @@ namespace OpenSim.ApplicationPlugins.Rest private IConfig _config; // Configuration source: Rest Plugins private IConfig _pluginConfig; // Configuration source: Plugin specific - private OpenSimMain _app; // The 'server' + private OpenSimBase _app; // The 'server' private BaseHttpServer _httpd; // The server's RPC interface private string _prefix; // URL prefix below // which all REST URLs @@ -114,7 +114,7 @@ namespace OpenSim.ApplicationPlugins.Rest /// /// OpenSimMain application /// - public OpenSimMain App + public OpenSimBase App { get { return _app; } } @@ -196,7 +196,7 @@ namespace OpenSim.ApplicationPlugins.Rest /// Note that entries MUST be added to the active configuration files before /// the plugin can be enabled. /// - public virtual void Initialise(OpenSimMain openSim) + public virtual void Initialise(OpenSimBase openSim) { RequestID = "0"; MsgID = RequestID; diff --git a/OpenSim/Region/Application/Application.cs b/OpenSim/Region/Application/Application.cs index 9aa885f..72fdf10 100644 --- a/OpenSim/Region/Application/Application.cs +++ b/OpenSim/Region/Application/Application.cs @@ -82,12 +82,12 @@ namespace OpenSim if (background) { - OpenSimMain sim = new OpenSimMain(configSource); + OpenSimBase sim = new OpenSimBackground(configSource); sim.StartUp(); } else { - OpenSimMain sim = new OpenSimMainConsole(configSource); + OpenSimBase sim = new OpenSim(configSource); sim.StartUp(); while (true) diff --git a/OpenSim/Region/Application/IApplicationPlugin.cs b/OpenSim/Region/Application/IApplicationPlugin.cs index 30f8da8..7ca4383 100644 --- a/OpenSim/Region/Application/IApplicationPlugin.cs +++ b/OpenSim/Region/Application/IApplicationPlugin.cs @@ -34,7 +34,7 @@ namespace OpenSim [TypeExtensionPoint("/OpenSim/Startup")] public interface IApplicationPlugin { - void Initialise(OpenSimMain openSim); + void Initialise(OpenSimBase openSim); void Close(); } } diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs new file mode 100644 index 0000000..1bed036 --- /dev/null +++ b/OpenSim/Region/Application/OpenSim.cs @@ -0,0 +1,680 @@ +/* + * 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 OpenSim 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.Collections; +using System.Collections.Generic; +using System.IO; +using System.Net; +using System.Reflection; +using System.Threading; +using libsecondlife; +using log4net; +using Nini.Config; +using OpenSim.Framework; +using OpenSim.Framework.Console; +using OpenSim.Framework.Statistics; +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Scenes; +using Timer=System.Timers.Timer; + +namespace OpenSim +{ + public delegate void ConsoleCommand(string[] comParams); + + /// + /// Interactive OpenSim region server + /// + public class OpenSim : OpenSimBase, conscmd_callback + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + protected string m_startupCommandsFile; + protected string m_shutdownCommandsFile; + + private string m_timedScript = "disabled"; + private Timer m_scriptTimer; + + public OpenSim(IConfigSource configSource) : base(configSource) + { + } + + protected override void ReadConfigSettings() + { + IConfig startupConfig = m_config.Configs["Startup"]; + + if (startupConfig != null) + { + m_startupCommandsFile = startupConfig.GetString("startup_console_commands_file", String.Empty); + m_shutdownCommandsFile = startupConfig.GetString("shutdown_console_commands_file", String.Empty); + + m_timedScript = startupConfig.GetString("timer_Script", "disabled"); + } + base.ReadConfigSettings(); + } + + /// + /// Performs initialisation of the scene, such as loading configuration from disk. + /// + public override void StartUp() + { + // + // Called from app startup (OpenSim.Application) + // + + m_log.Info("===================================================================="); + m_log.Info("========================= STARTING OPENSIM ========================="); + m_log.Info("===================================================================="); + m_log.InfoFormat("[OPENSIM MAIN]: Running in {0} mode", (m_sandbox ? "sandbox" : "grid")); + + m_console = CreateConsole(); + MainConsole.Instance = m_console; + InternalStartUp(); + + //Run Startup Commands + if (m_startupCommandsFile != String.Empty) + { + RunCommandScript(m_startupCommandsFile); + } + else + { + m_log.Info("[STARTUP]: No startup command script specified. Moving on..."); + } + + // Start timer script (run a script every xx seconds) + if (m_timedScript != "disabled") + { + m_scriptTimer = new Timer(); + m_scriptTimer.Enabled = true; + m_scriptTimer.Interval = 1200 * 1000; + m_scriptTimer.Elapsed += RunAutoTimerScript; + } + + PrintFileToConsole("startuplogo.txt"); + } + + protected ConsoleBase CreateConsole() + { + return new ConsoleBase("Region", this); + } + + private void RunAutoTimerScript(object sender, EventArgs e) + { + if (m_timedScript != "disabled") + { + RunCommandScript(m_timedScript); + } + } + + #region Console Commands + + /// + /// + /// + /// + private void RunCommandScript(string fileName) + { + m_log.Info("[COMMANDFILE]: Running " + fileName); + if (File.Exists(fileName)) + { + StreamReader readFile = File.OpenText(fileName); + string currentCommand; + while ((currentCommand = readFile.ReadLine()) != null) + { + if (currentCommand != String.Empty) + { + m_log.Info("[COMMANDFILE]: Running '" + currentCommand + "'"); + m_console.RunCommand(currentCommand); + } + } + } + else + { + m_log.Error("[COMMANDFILE]: Command script missing. Can not run commands"); + } + } + + private static void PrintFileToConsole(string fileName) + { + if (File.Exists(fileName)) + { + StreamReader readFile = File.OpenText(fileName); + string currentLine; + while ((currentLine = readFile.ReadLine()) != null) + { + m_log.Info("[!]" + currentLine); + } + } + } + + + /// + /// Runs commands issued by the server console from the operator + /// + /// The first argument of the parameter (the command) + /// Additional arguments passed to the command + public override void RunCmd(string command, string[] cmdparams) + { + base.RunCmd(command, cmdparams); + + switch (command) + { + case "clear-assets": + m_assetCache.Clear(); + break; + + case "set-time": + m_sceneManager.SetCurrentSceneTimePhase(Convert.ToInt32(cmdparams[0])); + break; + + case "force-update": + m_console.Notice("Updating all clients"); + m_sceneManager.ForceCurrentSceneClientUpdate(); + break; + + case "edit-scale": + if (cmdparams.Length == 4) + { + m_sceneManager.HandleEditCommandOnCurrentScene(cmdparams); + } + break; + + case "debug": + if (cmdparams.Length > 0) + { + Debug(cmdparams); + } + break; + + case "scene-debug": + if (cmdparams.Length == 3) + { + if (m_sceneManager.CurrentScene == null) + { + m_console.Error("CONSOLE", "Please use 'change-region ' first"); + } + else + { + m_sceneManager.CurrentScene.SetSceneCoreDebug(!Convert.ToBoolean(cmdparams[0]), !Convert.ToBoolean(cmdparams[1]), !Convert.ToBoolean(cmdparams[2])); + } + } + else + { + m_console.Error("scene-debug (where inside <> is true/false)"); + } + break; + + case "help": + m_console.Notice("alert - send alert to a designated user or all users."); + m_console.Notice(" alert [First] [Last] [Message] - send an alert to a user. Case sensitive."); + m_console.Notice(" alert general [Message] - send an alert to all users."); + m_console.Notice("backup - trigger a simulator backup"); + m_console.Notice("clear-assets - clear asset cache"); + m_console.Notice("create-region - creates a new region"); + m_console.Notice("create user - adds a new user."); + m_console.Notice("change-region [name] - sets the region that many of these commands affect."); + m_console.Notice("command-script [filename] - Execute command in a file."); + m_console.Notice("debug - debugging commands"); + m_console.Notice(" packet 0..255 - print incoming/outgoing packets (0=off)"); + m_console.Notice("scene-debug [scripting] [collision] [physics] - Enable/Disable debug stuff, each can be True/False"); + m_console.Notice("edit-scale [prim name] [x] [y] [z] - resize given prim"); + m_console.Notice("export-map [filename] - save image of world map"); + m_console.Notice("force-update - force an update of prims in the scene"); + m_console.Notice("load-xml [filename] - load prims from XML (DEPRECATED)"); + m_console.Notice("load-xml2 [filename] - load prims from XML using version 2 format"); + m_console.Notice("restart - disconnects all clients and restarts the sims in the instance."); + m_console.Notice("remove-region [name] - remove a region"); + m_console.Notice("save-xml [filename] - save prims to XML (DEPRECATED)"); + m_console.Notice("save-xml2 [filename] - save prims to XML using version 2 format"); + m_console.Notice("script - manually trigger scripts? or script commands?"); + m_console.Notice("set-time [x] - set the current scene time phase"); + m_console.Notice("show assets - show state of asset cache."); + m_console.Notice("show users - show info about connected users."); + m_console.Notice("show modules - shows info about loaded modules."); + m_console.Notice("show regions - show running region information."); + m_console.Notice("threads - list threads"); + m_console.Notice("config set section field value - set a config value"); + m_console.Notice("config get section field - get a config value"); + m_console.Notice("config save - save OpenSim.ini"); + m_console.Notice("terrain help - show help for terrain commands."); + break; + + case "threads": +// m_console.Notice("THREAD", Process.GetCurrentProcess().Threads.Count + " threads running:"); +// int _tc = 0; + +// foreach (ProcessThread pt in Process.GetCurrentProcess().Threads) +// { +// _tc++; +// m_console.Notice("THREAD", _tc + ": ID: " + pt.Id + ", Started: " + pt.StartTime.ToString() + ", CPU time: " + pt.TotalProcessorTime + ", Pri: " + pt.BasePriority.ToString() + ", State: " + pt.ThreadState.ToString()); +// } + + List threads = ThreadTracker.GetThreads(); + if (threads == null) + { + m_console.Notice("THREAD", "Thread tracking is only enabled in DEBUG mode."); + } + else + { + int _tc = 0; + m_console.Notice("THREAD", threads.Count + " threads are being tracked:"); + foreach (Thread t in threads) + { + _tc++; + m_console.Notice("THREAD", _tc + ": ID: " + t.ManagedThreadId.ToString() + ", Name: " + t.Name + ", Alive: " + t.IsAlive.ToString() + ", Pri: " + t.Priority.ToString() + ", State: " + t.ThreadState.ToString()); + } + } + + break; + case "save-xml": + m_log.Error("[CONSOLE]: PLEASE NOTE, save-xml is DEPRECATED and may be REMOVED soon. If you are using this and there is some reason you can't use save-xml2, please file a mantis detailing the reason."); + + if (cmdparams.Length > 0) + { + m_sceneManager.SaveCurrentSceneToXml(cmdparams[0]); + } + else + { + m_sceneManager.SaveCurrentSceneToXml(DEFAULT_PRIM_BACKUP_FILENAME); + } + break; + + case "load-xml": + m_log.Error("[CONSOLE]: PLEASE NOTE, load-xml is DEPRECATED and may be REMOVED soon. If you are using this and there is some reason you can't use load-xml2, please file a mantis detailing the reason."); + + LLVector3 loadOffset = new LLVector3(0, 0, 0); + if (cmdparams.Length > 0) + { + bool generateNewIDS = false; + if (cmdparams.Length > 1) + { + if (cmdparams[1] == "-newUID") + { + generateNewIDS = true; + } + if (cmdparams.Length > 2) + { + loadOffset.X = (float) Convert.ToDecimal(cmdparams[2]); + if (cmdparams.Length > 3) + { + loadOffset.Y = (float) Convert.ToDecimal(cmdparams[3]); + } + if (cmdparams.Length > 4) + { + loadOffset.Z = (float) Convert.ToDecimal(cmdparams[4]); + } + m_console.Error("loadOffsets = <" + loadOffset.X + "," + loadOffset.Y + "," + + loadOffset.Z + ">"); + } + } + m_sceneManager.LoadCurrentSceneFromXml(cmdparams[0], generateNewIDS, loadOffset); + } + else + { + m_sceneManager.LoadCurrentSceneFromXml(DEFAULT_PRIM_BACKUP_FILENAME, false, loadOffset); + } + break; + + case "save-xml2": + if (cmdparams.Length > 0) + { + m_sceneManager.SaveCurrentSceneToXml2(cmdparams[0]); + } + else + { + m_sceneManager.SaveCurrentSceneToXml2(DEFAULT_PRIM_BACKUP_FILENAME); + } + break; + + case "load-xml2": + if (cmdparams.Length > 0) + { + m_sceneManager.LoadCurrentSceneFromXml2(cmdparams[0]); + } + else + { + m_sceneManager.LoadCurrentSceneFromXml2(DEFAULT_PRIM_BACKUP_FILENAME); + } + break; + + case "load-oar": + m_log.Error("[CONSOLE]: Don't use me - I haven't yet been sufficiently implemented!"); + + if (cmdparams.Length > 0) + { + m_sceneManager.LoadArchiveToCurrentScene(cmdparams[0]); + } + else + { + m_sceneManager.LoadArchiveToCurrentScene(DEFAULT_OAR_BACKUP_FILENAME); + } + break; + + case "save-oar": + m_log.Error("[CONSOLE]: Don't use me - I haven't yet been sufficiently implemented!"); + + if (cmdparams.Length > 0) + { + m_sceneManager.SaveCurrentSceneToArchive(cmdparams[0]); + } + else + { + m_sceneManager.SaveCurrentSceneToArchive(DEFAULT_OAR_BACKUP_FILENAME); + } + break; + + case "plugin": + m_sceneManager.SendCommandToPluginModules(cmdparams); + break; + + case "command-script": + if (cmdparams.Length > 0) + { + RunCommandScript(cmdparams[0]); + } + break; + + case "backup": + m_sceneManager.BackupCurrentScene(); + break; + + case "alert": + m_sceneManager.HandleAlertCommandOnCurrentScene(cmdparams); + break; + + case "create": + CreateAccount(cmdparams); + break; + + case "create-region": + CreateRegion(new RegionInfo(cmdparams[0], "Regions/" + cmdparams[1],false), true); + break; + case "remove-region": + string regName = CombineParams(cmdparams, 0); + + Scene killScene; + if (m_sceneManager.TryGetScene(regName, out killScene)) + { + // only need to check this if we are not at the + // root level + if ((m_sceneManager.CurrentScene != null) && + (m_sceneManager.CurrentScene.RegionInfo.RegionID == killScene.RegionInfo.RegionID)) + { + m_sceneManager.TrySetCurrentScene(".."); + } + m_regionData.Remove(killScene.RegionInfo); + m_sceneManager.CloseScene(killScene); + } + break; + + case "restart": + m_sceneManager.RestartCurrentScene(); + break; + + case "change-region": + if (cmdparams.Length > 0) + { + string regionName = CombineParams(cmdparams, 0); + + if (!m_sceneManager.TrySetCurrentScene(regionName)) + { + m_console.Error("Couldn't set current region to: " + regionName); + } + } + + if (m_sceneManager.CurrentScene == null) + { + m_console.Error("CONSOLE", "Currently at Root level. To change region please use 'change-region '"); + } + else + { + m_console.Error("CONSOLE", "Current Region: " + m_sceneManager.CurrentScene.RegionInfo.RegionName + + ". To change region please use 'change-region '"); + } + + break; + + case "export-map": + if (cmdparams.Length > 0) + { + m_sceneManager.CurrentOrFirstScene.ExportWorldMap(cmdparams[0]); + } + else + { + m_sceneManager.CurrentOrFirstScene.ExportWorldMap("exportmap.jpg"); + } + break; + + case "config": + string n = command.ToUpper(); + if (cmdparams.Length > 0) + { + switch (cmdparams[0].ToLower()) + { + case "set": + if (cmdparams.Length < 4) + { + m_console.Error(n, "SYNTAX: " + n + " SET SECTION KEY VALUE"); + m_console.Error(n, "EXAMPLE: " + n + " SET ScriptEngine.DotNetEngine NumberOfScriptThreads 5"); + } + else + { + IConfig c = DefaultConfig().Configs[cmdparams[1]]; + if (c == null) + c = DefaultConfig().AddConfig(cmdparams[1]); + string _value = String.Join(" ", cmdparams, 3, cmdparams.Length - 3); + c.Set(cmdparams[2], _value); + m_config.Merge(c.ConfigSource); + + m_console.Error(n, n + " " + n + " " + cmdparams[1] + " " + cmdparams[2] + " " + + _value); + } + break; + case "get": + if (cmdparams.Length < 3) + { + m_console.Error(n, "SYNTAX: " + n + " GET SECTION KEY"); + m_console.Error(n, "EXAMPLE: " + n + " GET ScriptEngine.DotNetEngine NumberOfScriptThreads"); + } + else + { + IConfig c = DefaultConfig().Configs[cmdparams[1]]; + if (c == null) + { + m_console.Notice(n, "Section \"" + cmdparams[1] + "\" does not exist."); + break; + } + else + { + m_console.Notice(n + " GET " + cmdparams[1] + " " + cmdparams[2] + ": " + + c.GetString(cmdparams[2])); + } + } + + break; + case "save": + m_console.Notice("Saving configuration file: " + Application.iniFilePath); + m_config.Save(Application.iniFilePath); + break; + } + } + break; + case "modules": + if (cmdparams.Length > 0) + { + switch (cmdparams[0].ToLower()) + { + case "list": + foreach (IRegionModule irm in m_moduleLoader.GetLoadedSharedModules) + { + m_console.Notice("Shared region module: " + irm.Name); + } + break; + case "unload": + if (cmdparams.Length > 1) + { + foreach (IRegionModule rm in new ArrayList(m_moduleLoader.GetLoadedSharedModules)) + { + if (rm.Name.ToLower() == cmdparams[1].ToLower()) + { + m_console.Notice("Unloading module: " + rm.Name); + m_moduleLoader.UnloadModule(rm); + } + } + } + break; + case "load": + if (cmdparams.Length > 1) + { + foreach (Scene s in new ArrayList(m_sceneManager.Scenes)) + { + + m_console.Notice("Loading module: " + cmdparams[1]); + m_moduleLoader.LoadRegionModules(cmdparams[1], s); + } + } + break; + } + } + + break; + default: + string[] tmpPluginArgs = new string[cmdparams.Length + 1]; + cmdparams.CopyTo(tmpPluginArgs, 1); + tmpPluginArgs[0] = command; + + m_sceneManager.SendCommandToPluginModules(tmpPluginArgs); + break; + } + } + + public void Debug(string[] args) + { + switch (args[0]) + { + case "packet": + if (args.Length > 1) + { + int newDebug; + if (int.TryParse(args[1], out newDebug)) + { + m_sceneManager.SetDebugPacketOnCurrentScene(newDebug); + } + else + { + m_console.Error("packet debug should be 0..2"); + } + m_console.Notice("New packet debug: " + newDebug.ToString()); + } + + break; + default: + m_console.Error("Unknown debug"); + break; + } + } + + // see BaseOpenSimServer + public override void Show(string ShowWhat) + { + base.Show(ShowWhat); + + switch (ShowWhat) + { + case "assets": + m_assetCache.ShowState(); + break; + + case "users": + IList agents = m_sceneManager.GetCurrentSceneAvatars(); + + m_console.Notice(String.Format("\nAgents connected: {0}\n", agents.Count)); + + m_console.Notice( + String.Format("{0,-16}{1,-16}{2,-37}{3,-16}", "Firstname", "Lastname", + "Agent ID","Region")); + + foreach (ScenePresence presence in agents) + { + RegionInfo regionInfo = m_sceneManager.GetRegionInfo(presence.RegionHandle); + string regionName; + + if (regionInfo == null) + { + regionName = "Unresolvable"; + } + else + { + regionName = regionInfo.RegionName; + } + + m_console.Notice( + String.Format( + "{0,-16}{1,-16}{2,-37}{3,-16}", + presence.Firstname, + presence.Lastname, + presence.UUID, + regionName)); + } + + m_console.Notice(""); + break; + + case "modules": + m_console.Notice("The currently loaded shared modules are:"); + foreach (IRegionModule module in m_moduleLoader.GetLoadedSharedModules) + { + m_console.Notice("Shared Module: " + module.Name); + } + break; + + case "regions": + m_sceneManager.ForEachScene( + delegate(Scene scene) + { + m_console.Notice("Region Name: " + scene.RegionInfo.RegionName + " , Region XLoc: " + + scene.RegionInfo.RegionLocX + " , Region YLoc: " + + scene.RegionInfo.RegionLocY); + }); + break; + } + } + + private static string CombineParams(string[] commandParams, int pos) + { + string result = String.Empty; + for (int i = pos; i < commandParams.Length; i++) + { + result += commandParams[i] + " "; + } + result = result.TrimEnd(' '); + return result; + } + + #endregion + } +} diff --git a/OpenSim/Region/Application/OpenSimBackground.cs b/OpenSim/Region/Application/OpenSimBackground.cs new file mode 100644 index 0000000..0c3a0a3 --- /dev/null +++ b/OpenSim/Region/Application/OpenSimBackground.cs @@ -0,0 +1,80 @@ +/* + * 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 OpenSim 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.Reflection; +using System.Threading; +using log4net; +using Nini.Config; + +namespace OpenSim +{ + /// + /// Consoleless OpenSim region server + /// + public class OpenSimBackground : OpenSimBase + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private ManualResetEvent WorldHasComeToAnEnd = new ManualResetEvent(false); + + public OpenSimBackground(IConfigSource configSource) : base(configSource) + { + } + + /// + /// Performs initialisation of the scene, such as loading configuration from disk. + /// + public override void StartUp() + { + // + // Called from app startup (OpenSim.Application) + // + m_log.Info("===================================================================="); + m_log.Info("========================= STARTING OPENSIM ========================="); + m_log.Info("===================================================================="); + m_log.InfoFormat("[OPENSIM MAIN]: Running in background {0} mode", m_sandbox ? "sandbox" : "grid"); + + InternalStartUp(); + + // We are done with startup + m_log.InfoFormat("[OPENSIM MAIN]: Startup complete, serving {0} region{1}", + m_clientServers.Count.ToString(), m_clientServers.Count > 1 ? "s" : ""); + + WorldHasComeToAnEnd.WaitOne(); + } + + /// + /// Performs any last-minute sanity checking and shuts down the region server + /// + public override void Shutdown() + { + WorldHasComeToAnEnd.Set(); + + base.Shutdown(); + } + } +} diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs new file mode 100644 index 0000000..468881e --- /dev/null +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -0,0 +1,702 @@ +/* + * 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 OpenSim 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.Collections.Generic; +using System.IO; +using System.Net; +using System.Reflection; +using System.Text; +using System.Threading; +using libsecondlife; +using log4net; +using Mono.Addins; +using Nini.Config; +using OpenSim.Framework; +using OpenSim.Framework.Communications.Cache; +using OpenSim.Framework.Servers; +using OpenSim.Framework.Statistics; +using OpenSim.Region.ClientStack; +using OpenSim.Region.Communications.Local; +using OpenSim.Region.Communications.OGS1; +using OpenSim.Region.Environment; +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.Physics.Manager; + +namespace OpenSim +{ + /// + /// Common OpenSim region service code + /// + public class OpenSimBase : RegionApplicationBase + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + protected string proxyUrl; + protected int proxyOffset = 0; + + /// + /// The file used to load and save prim backup xml if none has been specified + /// + protected const string DEFAULT_PRIM_BACKUP_FILENAME = "prim-backup.xml"; + + /// + /// The file use to load and save an opensim archive if none has been specified + /// + protected const string DEFAULT_OAR_BACKUP_FILENAME = "scene.oar.tar"; + + public string m_physicsEngine; + public string m_meshEngineName; + public string m_scriptEngine; + public bool m_sandbox; + public bool user_accounts; + public bool m_gridLocalAsset; + public bool m_see_into_region_from_neighbor; + + protected LocalLoginService m_loginService; + + protected string m_storageDll; + + protected List m_clientServers = new List(); + protected List m_regionData = new List(); + + protected bool m_physicalPrim; + + protected bool m_standaloneAuthenticate = false; + protected string m_standaloneWelcomeMessage = null; + protected string m_standaloneInventoryPlugin; + protected string m_standaloneAssetPlugin; + protected string m_standaloneUserPlugin; + + private string m_standaloneInventorySource; + private string m_standaloneAssetSource; + private string m_standaloneUserSource; + + protected string m_assetStorage = "local"; + + public ConsoleCommand CreateAccount = null; + protected bool m_dumpAssetsToFile; + + protected List m_plugins = new List(); + + protected IConfigSource m_finalConfig = null; + + protected IniConfigSource m_config; + + public IniConfigSource ConfigSource + { + get { return m_config; } + set { m_config = value; } + } + + public List ClientServers + { + get { return m_clientServers; } + } + + public List RegionData + { + get { return m_regionData; } + } + + public new BaseHttpServer HttpServer + { + get { return m_httpServer; } + } + + public new uint HttpServerPort + { + get { return m_httpServerPort; } + } + + protected ModuleLoader m_moduleLoader; + + public ModuleLoader ModuleLoader + { + get { return m_moduleLoader; } + set { m_moduleLoader = value; } + } + + public OpenSimBase(IConfigSource configSource) + : base() + { + IConfig startupConfig = configSource.Configs["Startup"]; + + // The Mono addin manager (in Mono.Addins.dll version 0.2.0.0) occasionally seems to corrupt its addin cache + // Hence, as a temporary solution we'll remove it before each startup + if (Directory.Exists("addin-db-000")) + Directory.Delete("addin-db-000", true); + + if (Directory.Exists("addin-db-001")) + Directory.Delete("addin-db-001", true); + + // This blocks the scanning warnings from outputing to the console. + TextWriter oldOutput = Console.Out; + Console.SetOut(new StreamWriter(Stream.Null)); + + AddinManager.Initialize("."); + AddinManager.Registry.Update(null); + + // Returns the console.writelines back to the console's stream + Console.SetOut(oldOutput); + + Application.iniFilePath = startupConfig.GetString("inifile", "OpenSim.ini"); + + m_config = new IniConfigSource(); + //check for .INI file (either default or name passed in command line) + if (File.Exists(Application.iniFilePath)) + { + m_config.Merge(new IniConfigSource(Application.iniFilePath)); + m_config.Merge(configSource); + } + else + { + Application.iniFilePath = Path.Combine(Util.configDir(), Application.iniFilePath); + if (File.Exists(Application.iniFilePath)) + { + m_config.Merge(new IniConfigSource(Application.iniFilePath)); + m_config.Merge(configSource); + } + else + { + // no default config files, so set default values, and save it + m_config.Merge(DefaultConfig()); + m_config.Merge(configSource); + m_config.Save(Application.iniFilePath); + } + } + + ReadConfigSettings(); + } + + public static IConfigSource DefaultConfig() + { + IConfigSource DefaultConfig = new IniConfigSource(); + if (DefaultConfig.Configs["Startup"] == null) + DefaultConfig.AddConfig("Startup"); + IConfig config = DefaultConfig.Configs["Startup"]; + if (config != null) + { + config.Set("gridmode", false); + config.Set("physics", "basicphysics"); + config.Set("physical_prim", true); + config.Set("see_into_this_sim_from_neighbor", true); + config.Set("serverside_object_permissions", false); + config.Set("storage_plugin", "OpenSim.Data.SQLite.dll"); + config.Set("storage_connection_string", "URI=file:OpenSim.db,version=3"); + config.Set("storage_prim_inventories", true); + config.Set("startup_console_commands_file", String.Empty); + config.Set("shutdown_console_commands_file", String.Empty); + config.Set("script_engine", "OpenSim.Region.ScriptEngine.DotNetEngine.dll"); + config.Set("asset_database", "sqlite"); + } + + if (DefaultConfig.Configs["StandAlone"] == null) + DefaultConfig.AddConfig("StandAlone"); + + config = DefaultConfig.Configs["StandAlone"]; + if (config != null) + { + config.Set("accounts_authenticate", false); + config.Set("welcome_message", "Welcome to OpenSimulator"); + config.Set("inventory_plugin", "OpenSim.Data.SQLite.dll"); + config.Set("inventory_source", ""); + config.Set("userDatabase_plugin", "OpenSim.Data.SQLite.dll"); + config.Set("user_source", ""); + config.Set("asset_plugin", "OpenSim.Data.SQLite.dll"); + config.Set("asset_source", ""); + config.Set("dump_assets_to_file", false); + } + + if (DefaultConfig.Configs["Network"] == null) + DefaultConfig.AddConfig("Network"); + config = DefaultConfig.Configs["Network"]; + if (config != null) + { + config.Set("default_location_x", 1000); + config.Set("default_location_y", 1000); + config.Set("http_listener_port", NetworkServersInfo.DefaultHttpListenerPort); + config.Set("remoting_listener_port", NetworkServersInfo.RemotingListenerPort); + config.Set("grid_server_url", "http://127.0.0.1:" + GridConfig.DefaultHttpPort.ToString()); + config.Set("grid_send_key", "null"); + config.Set("grid_recv_key", "null"); + config.Set("user_server_url", "http://127.0.0.1:" + UserConfig.DefaultHttpPort.ToString()); + config.Set("user_send_key", "null"); + config.Set("user_recv_key", "null"); + config.Set("asset_server_url", "http://127.0.0.1:" + AssetConfig.DefaultHttpPort.ToString()); + config.Set("inventory_server_url", "http://127.0.0.1:" + InventoryConfig.DefaultHttpPort.ToString()); + } + + if (DefaultConfig.Configs["RemoteAdmin"] == null) + DefaultConfig.AddConfig("RemoteAdmin"); + config = DefaultConfig.Configs["RemoteAdmin"]; + if (config != null) + { + config.Set("enabled", "false"); + } + + if (DefaultConfig.Configs["Voice"] == null) + DefaultConfig.AddConfig("Voice"); + config = DefaultConfig.Configs["Voice"]; + if (config != null) + { + config.Set("enabled", "false"); + } + return DefaultConfig; + + } + + protected virtual void ReadConfigSettings() + { + m_networkServersInfo = new NetworkServersInfo(); + + IConfig startupConfig = m_config.Configs["Startup"]; + + if (startupConfig != null) + { + m_sandbox = !startupConfig.GetBoolean("gridmode", false); + m_physicsEngine = startupConfig.GetString("physics", "basicphysics"); + m_meshEngineName = startupConfig.GetString("meshing", "ZeroMesher"); + + m_physicalPrim = startupConfig.GetBoolean("physical_prim", true); + + m_see_into_region_from_neighbor = startupConfig.GetBoolean("see_into_this_sim_from_neighbor", true); + + m_storageDll = startupConfig.GetString("storage_plugin", "OpenSim.Data.SQLite.dll"); + if (m_storageDll == "OpenSim.DataStore.MonoSqlite.dll") + { + m_storageDll = "OpenSim.Data.SQLite.dll"; + Console.WriteLine("WARNING: OpenSim.DataStore.MonoSqlite.dll is deprecated. Set storage_plugin to OpenSim.Data.SQLite.dll."); + Thread.Sleep(3000); + } + m_storageConnectionString + = startupConfig.GetString("storage_connection_string", "URI=file:OpenSim.db,version=3"); + m_storagePersistPrimInventories + = startupConfig.GetBoolean("storage_prim_inventories", true); + + m_scriptEngine = startupConfig.GetString("script_engine", "OpenSim.Region.ScriptEngine.DotNetEngine.dll"); + m_assetStorage = startupConfig.GetString("asset_database", "local"); + } + + IConfig standaloneConfig = m_config.Configs["StandAlone"]; + if (standaloneConfig != null) + { + m_standaloneAuthenticate = standaloneConfig.GetBoolean("accounts_authenticate", false); + m_standaloneWelcomeMessage = standaloneConfig.GetString("welcome_message", "Welcome to OpenSim"); + m_standaloneInventoryPlugin = + standaloneConfig.GetString("inventory_plugin", "OpenSim.Data.SQLite.dll"); + m_standaloneInventorySource = + standaloneConfig.GetString("inventory_source",""); + m_standaloneUserPlugin = + standaloneConfig.GetString("userDatabase_plugin", "OpenSim.Data.SQLite.dll"); + m_standaloneUserSource = + standaloneConfig.GetString("user_source",""); + m_standaloneAssetPlugin = + standaloneConfig.GetString("asset_plugin", "OpenSim.Data.SQLite.dll"); + m_standaloneAssetSource = + standaloneConfig.GetString("asset_source",""); + + m_dumpAssetsToFile = standaloneConfig.GetBoolean("dump_assets_to_file", false); + } + + m_networkServersInfo.loadFromConfiguration(m_config); + } + + /// + /// Performs initialisation of the scene, such as loading configuration from disk. + /// + protected void InternalStartUp() + { + m_log.Info("[STARTUP]: Version " + m_version + "\n"); + + m_stats = StatsManager.StartCollectingSimExtraStats(); + + // Do baseclass startup sequence: OpenSim.Region.ClientStack.RegionApplicationBase.StartUp + // TerrainManager, StorageManager, HTTP Server + // This base will call abstract Initialize + base.StartUp(); + + // StandAlone mode? m_sandbox is determined by !startupConfig.GetBoolean("gridmode", false) + if (m_sandbox) + { + LocalInventoryService inventoryService = new LocalInventoryService(); + inventoryService.AddPlugin(m_standaloneInventoryPlugin, m_standaloneInventorySource); + + LocalUserServices userService = + new LocalUserServices(m_networkServersInfo, m_networkServersInfo.DefaultHomeLocX, + m_networkServersInfo.DefaultHomeLocY, inventoryService); + userService.AddPlugin(m_standaloneUserPlugin, m_standaloneUserSource); + + LocalBackEndServices backendService = new LocalBackEndServices(); + + CommunicationsLocal localComms = + new CommunicationsLocal(m_networkServersInfo, m_httpServer, m_assetCache, userService, + inventoryService, backendService, backendService, m_dumpAssetsToFile); + m_commsManager = localComms; + + m_loginService = + new LocalLoginService(userService, m_standaloneWelcomeMessage, localComms, m_networkServersInfo, + m_standaloneAuthenticate); + m_loginService.OnLoginToRegion += backendService.AddNewSession; + + // set up XMLRPC handler for client's initial login request message + m_httpServer.AddXmlRPCHandler("login_to_simulator", m_loginService.XmlRpcLoginMethod); + + // provides the web form login + m_httpServer.AddHTTPHandler("login", m_loginService.ProcessHTMLLogin); + + // Provides the LLSD login + m_httpServer.SetLLSDHandler(m_loginService.LLSDLoginMethod); + + CreateAccount = localComms.doCreate; + } + else + { + // We are in grid mode + m_commsManager = new CommunicationsOGS1(m_networkServersInfo, m_httpServer, m_assetCache); + m_httpServer.AddStreamHandler(new SimStatusHandler()); + } + + proxyUrl = ConfigSource.Configs["Network"].GetString("proxy_url", ""); + proxyOffset = Int32.Parse(ConfigSource.Configs["Network"].GetString("proxy_offset", "0")); + + // Create a ModuleLoader instance + m_moduleLoader = new ModuleLoader(m_config); + + ExtensionNodeList nodes = AddinManager.GetExtensionNodes("/OpenSim/Startup"); + foreach (TypeExtensionNode node in nodes) + { + m_log.InfoFormat("[PLUGINS]: Loading OpenSim application plugin {0}", node.Path); + IApplicationPlugin plugin = (IApplicationPlugin)node.CreateInstance(); + plugin.Initialise(this); + m_plugins.Add(plugin); + } + } + + protected override void Initialize() + { + // + // Called from base.StartUp() + // + + m_httpServerPort = m_networkServersInfo.HttpListenerPort; + + IAssetServer assetServer; + if (m_assetStorage == "grid") + { + assetServer = new GridAssetClient(m_networkServersInfo.AssetURL); + } + else + { + SQLAssetServer sqlAssetServer = new SQLAssetServer(m_standaloneAssetPlugin, m_standaloneAssetSource); + sqlAssetServer.LoadDefaultAssets(); + assetServer = sqlAssetServer; + } + + m_assetCache = new AssetCache(assetServer); + + m_sceneManager.OnRestartSim += handleRestartRegion; + } + + public LLUUID CreateUser(string tempfirstname, string templastname, string tempPasswd, uint regX, uint regY) + { + return m_commsManager.AddUser(tempfirstname,templastname,tempPasswd,regX,regY); + } + + /// + /// Execute the region creation process. This includes setting up scene infrastructure. + /// + /// + /// + /// + public IClientNetworkServer CreateRegion(RegionInfo regionInfo, bool portadd_flag) + { + return CreateRegion(regionInfo, portadd_flag, false); + } + + /// + /// Execute the region creation process. This includes setting up scene infrastructure. + /// + /// + /// + /// + public IClientNetworkServer CreateRegion(RegionInfo regionInfo) + { + return CreateRegion(regionInfo, false, true); + } + + /// + /// Execute the region creation process. This includes setting up scene infrastructure. + /// + /// + /// + /// + /// + public IClientNetworkServer CreateRegion(RegionInfo regionInfo, bool portadd_flag, bool do_post_init) + { + int port = regionInfo.InternalEndPoint.Port; + + // set initial RegionID to originRegionID in RegionInfo. (it needs for loding prims) + regionInfo.originRegionID = regionInfo.RegionID; + + // set initial ServerURI + regionInfo.ServerURI = "http://" + regionInfo.ExternalHostName + + ":" + regionInfo.InternalEndPoint.Port.ToString(); + + regionInfo.HttpPort = m_httpServerPort; + + if ((proxyUrl.Length > 0) && (portadd_flag)) + { + // set proxy url to RegionInfo + regionInfo.proxyUrl = proxyUrl; + Util.XmlRpcCommand(proxyUrl, "AddPort", port, port + proxyOffset, regionInfo.ExternalHostName); + } + + IClientNetworkServer clientServer; + Scene scene = SetupScene(regionInfo, proxyOffset, out clientServer); + + m_log.Info("[MODULES]: Loading Region's modules"); + + List modules = m_moduleLoader.PickupModules(scene, "."); + // This needs to be ahead of the script engine load, so the + // script module can pick up events exposed by a module + m_moduleLoader.InitialiseSharedModules(scene); + + //m_moduleLoader.PickupModules(scene, "ScriptEngines"); + //m_moduleLoader.LoadRegionModules(Path.Combine("ScriptEngines", m_scriptEngine), scene); + + if (string.IsNullOrEmpty(m_scriptEngine)) + { + m_log.Info("[MODULES]: No script engien module specified"); + } + else + { + m_log.Info("[MODULES]: Loading scripting engine modules"); + foreach (string module in m_scriptEngine.Split(',')) + { + string mod = module.Trim(" \t".ToCharArray()); // Clean up name + m_log.Info("[MODULES]: Loading scripting engine: " + mod); + try + { + m_moduleLoader.LoadRegionModules(Path.Combine("ScriptEngines", mod), scene); + } + catch (Exception ex) + { + m_log.Error("[MODULES]: Failed to load script engine: " + ex.ToString()); + } + } + } + + scene.SetModuleInterfaces(); + + //moved these here as the terrain texture has to be created after the modules are initialized + // and has to happen before the region is registered with the grid. + scene.CreateTerrainTexture(true); + + try + { + scene.RegisterRegionWithGrid(); + } + catch (Exception e) + { + m_log.ErrorFormat("[STARTUP]: Registration of region with grid failed, aborting startup - {0}", e); + + // Carrying on now causes a lot of confusion down the line - we need to get the user's attention + System.Environment.Exit(1); + } + + // We need to do this after we've initialized the scripting engines. + scene.StartScripts(); + + scene.loadAllLandObjectsFromStorage(regionInfo.originRegionID); + scene.EventManager.TriggerParcelPrimCountUpdate(); + + m_sceneManager.Add(scene); + + m_clientServers.Add(clientServer); + m_regionData.Add(regionInfo); + clientServer.Start(); + + if (do_post_init) + { + foreach (IRegionModule module in modules) + { + module.PostInitialise(); + } + } + + return clientServer; + } + + protected override StorageManager CreateStorageManager(string connectionstring) + { + return new StorageManager(m_storageDll, connectionstring, m_storagePersistPrimInventories); + } + + protected override Scene CreateScene(RegionInfo regionInfo, StorageManager storageManager, + AgentCircuitManager circuitManager) + { + SceneCommunicationService sceneGridService = new SceneCommunicationService(m_commsManager); + return + new Scene(regionInfo, circuitManager, m_commsManager, sceneGridService, m_assetCache, + storageManager, m_httpServer, + m_moduleLoader, m_dumpAssetsToFile, m_physicalPrim, m_see_into_region_from_neighbor, m_config, + m_version); + + } + + public void handleRestartRegion(RegionInfo whichRegion) + { + m_log.Error("[OPENSIM MAIN]: Got restart signal from SceneManager"); + + // Shutting down the client server + bool foundClientServer = false; + int clientServerElement = 0; + + for (int i = 0; i < m_clientServers.Count; i++) + { + if (m_clientServers[i].HandlesRegion(new Location(whichRegion.RegionHandle))) + { + clientServerElement = i; + foundClientServer = true; + break; + } + } + if (foundClientServer) + { + m_clientServers[clientServerElement].Server.Close(); + m_clientServers.RemoveAt(clientServerElement); + } + + //Removing the region from the sim's database of regions.. + int RegionHandleElement = -1; + for (int i = 0; i < m_regionData.Count; i++) + { + if (whichRegion.RegionHandle == m_regionData[i].RegionHandle) + { + RegionHandleElement = i; + } + } + if (RegionHandleElement >= 0) + { + m_regionData.RemoveAt(RegionHandleElement); + } + + CreateRegion(whichRegion, true); + } + + # region Setup methods + + protected override PhysicsScene GetPhysicsScene() + { + return GetPhysicsScene(m_physicsEngine, m_meshEngineName, m_config); + } + + /// + /// Handler to supply the current status of this sim + /// + /// Currently this is always OK if the simulator is still listening for connections on its HTTP service + /// + protected class SimStatusHandler : IStreamedRequestHandler + { + public byte[] Handle(string path, Stream request, + OSHttpRequest httpRequest, OSHttpResponse httpResponse) + { + return Encoding.UTF8.GetBytes("OK"); + } + + public string ContentType + { + get { return "text/plain"; } + } + + public string HttpMethod + { + get { return "GET"; } + } + + public string Path + { + get { return "/simstatus/"; } + } + } + + #endregion + + /// + /// Performs any last-minute sanity checking and shuts down the region server + /// + public override void Shutdown() + { + if (proxyUrl.Length > 0) + { + Util.XmlRpcCommand(proxyUrl, "Stop"); + } + + m_log.Info("[SHUTDOWN]: Closing all threads"); + m_log.Info("[SHUTDOWN]: Killing listener thread"); + m_log.Info("[SHUTDOWN]: Killing clients"); + // TODO: implement this + m_log.Info("[SHUTDOWN]: Closing console and terminating"); + + m_sceneManager.Close(); + + base.Shutdown(); + } + + /// + /// Get the start time and up time of Region server + /// + /// The first out parameter describing when the Region server started + /// The second out parameter describing how long the Region server has run + public void GetRunTime(out string starttime, out string uptime) + { + starttime = m_startuptime.ToString(); + uptime = (DateTime.Now - m_startuptime).ToString(); + } + + /// + /// Get the number of the avatars in the Region server + /// + /// The first out parameter describing the number of all the avatars in the Region server + public void GetAvatarNumber(out int usernum) + { + usernum = m_sceneManager.GetCurrentSceneAvatars().Count; + } + + /// + /// Get the number of regions + /// + /// The first out parameter describing the number of regions + public void GetRegionNumber(out int regionnum) + { + regionnum = m_sceneManager.Scenes.Count; + } + } +} + diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs deleted file mode 100644 index 03dbf78..0000000 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ /dev/null @@ -1,729 +0,0 @@ -/* - * 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 OpenSim 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.Collections.Generic; -using System.IO; -using System.Net; -using System.Reflection; -using System.Text; -using System.Threading; -using libsecondlife; -using log4net; -using Mono.Addins; -using Nini.Config; -using OpenSim.Framework; -using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Servers; -using OpenSim.Framework.Statistics; -using OpenSim.Region.ClientStack; -using OpenSim.Region.Communications.Local; -using OpenSim.Region.Communications.OGS1; -using OpenSim.Region.Environment; -using OpenSim.Region.Environment.Interfaces; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Physics.Manager; - -namespace OpenSim -{ - public class OpenSimMain : RegionApplicationBase - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - protected string proxyUrl; - protected int proxyOffset = 0; - - /// - /// The file used to load and save prim backup xml if none has been specified - /// - protected const string DEFAULT_PRIM_BACKUP_FILENAME = "prim-backup.xml"; - - /// - /// The file use to load and save an opensim archive if none has been specified - /// - protected const string DEFAULT_OAR_BACKUP_FILENAME = "scene.oar.tar"; - - public string m_physicsEngine; - public string m_meshEngineName; - public string m_scriptEngine; - public bool m_sandbox; - public bool user_accounts; - public bool m_gridLocalAsset; - public bool m_see_into_region_from_neighbor; - - protected LocalLoginService m_loginService; - - protected string m_storageDll; - - protected List m_clientServers = new List(); - protected List m_regionData = new List(); - - protected bool m_physicalPrim; - - protected bool m_standaloneAuthenticate = false; - protected string m_standaloneWelcomeMessage = null; - protected string m_standaloneInventoryPlugin; - protected string m_standaloneAssetPlugin; - protected string m_standaloneUserPlugin; - - private string m_standaloneInventorySource; - private string m_standaloneAssetSource; - private string m_standaloneUserSource; - - protected string m_assetStorage = "local"; - - public ConsoleCommand CreateAccount = null; - protected bool m_dumpAssetsToFile; - - protected List m_plugins = new List(); - - protected IConfigSource m_finalConfig = null; - - protected IniConfigSource m_config; - - public IniConfigSource ConfigSource - { - get { return m_config; } - set { m_config = value; } - } - - public List ClientServers - { - get { return m_clientServers; } - } - - public List RegionData - { - get { return m_regionData; } - } - - public new BaseHttpServer HttpServer - { - get { return m_httpServer; } - } - - public new uint HttpServerPort - { - get { return m_httpServerPort; } - } - - protected ModuleLoader m_moduleLoader; - - public ModuleLoader ModuleLoader - { - get { return m_moduleLoader; } - set { m_moduleLoader = value; } - } - - public OpenSimMain(IConfigSource configSource) - : base() - { - IConfig startupConfig = configSource.Configs["Startup"]; - - // The Mono addin manager (in Mono.Addins.dll version 0.2.0.0) occasionally seems to corrupt its addin cache - // Hence, as a temporary solution we'll remove it before each startup - if (Directory.Exists("addin-db-000")) - Directory.Delete("addin-db-000", true); - - if (Directory.Exists("addin-db-001")) - Directory.Delete("addin-db-001", true); - - // This blocks the scanning warnings from outputing to the console. - TextWriter oldOutput = Console.Out; - Console.SetOut(new StreamWriter(Stream.Null)); - - AddinManager.Initialize("."); - AddinManager.Registry.Update(null); - - // Returns the console.writelines back to the console's stream - Console.SetOut(oldOutput); - - Application.iniFilePath = startupConfig.GetString("inifile", "OpenSim.ini"); - - m_config = new IniConfigSource(); - //check for .INI file (either default or name passed in command line) - if (File.Exists(Application.iniFilePath)) - { - m_config.Merge(new IniConfigSource(Application.iniFilePath)); - m_config.Merge(configSource); - } - else - { - Application.iniFilePath = Path.Combine(Util.configDir(), Application.iniFilePath); - if (File.Exists(Application.iniFilePath)) - { - m_config.Merge(new IniConfigSource(Application.iniFilePath)); - m_config.Merge(configSource); - } - else - { - // no default config files, so set default values, and save it - m_config.Merge(DefaultConfig()); - m_config.Merge(configSource); - m_config.Save(Application.iniFilePath); - } - } - - ReadConfigSettings(); - } - - public static IConfigSource DefaultConfig() - { - IConfigSource DefaultConfig = new IniConfigSource(); - if (DefaultConfig.Configs["Startup"] == null) - DefaultConfig.AddConfig("Startup"); - IConfig config = DefaultConfig.Configs["Startup"]; - if (config != null) - { - config.Set("gridmode", false); - config.Set("physics", "basicphysics"); - config.Set("physical_prim", true); - config.Set("see_into_this_sim_from_neighbor", true); - config.Set("serverside_object_permissions", false); - config.Set("storage_plugin", "OpenSim.Data.SQLite.dll"); - config.Set("storage_connection_string", "URI=file:OpenSim.db,version=3"); - config.Set("storage_prim_inventories", true); - config.Set("startup_console_commands_file", String.Empty); - config.Set("shutdown_console_commands_file", String.Empty); - config.Set("script_engine", "OpenSim.Region.ScriptEngine.DotNetEngine.dll"); - config.Set("asset_database", "sqlite"); - } - - if (DefaultConfig.Configs["StandAlone"] == null) - DefaultConfig.AddConfig("StandAlone"); - - config = DefaultConfig.Configs["StandAlone"]; - if (config != null) - { - config.Set("accounts_authenticate", false); - config.Set("welcome_message", "Welcome to OpenSimulator"); - config.Set("inventory_plugin", "OpenSim.Data.SQLite.dll"); - config.Set("inventory_source", ""); - config.Set("userDatabase_plugin", "OpenSim.Data.SQLite.dll"); - config.Set("user_source", ""); - config.Set("asset_plugin", "OpenSim.Data.SQLite.dll"); - config.Set("asset_source", ""); - config.Set("dump_assets_to_file", false); - } - - if (DefaultConfig.Configs["Network"] == null) - DefaultConfig.AddConfig("Network"); - config = DefaultConfig.Configs["Network"]; - if (config != null) - { - config.Set("default_location_x", 1000); - config.Set("default_location_y", 1000); - config.Set("http_listener_port", NetworkServersInfo.DefaultHttpListenerPort); - config.Set("remoting_listener_port", NetworkServersInfo.RemotingListenerPort); - config.Set("grid_server_url", "http://127.0.0.1:" + GridConfig.DefaultHttpPort.ToString()); - config.Set("grid_send_key", "null"); - config.Set("grid_recv_key", "null"); - config.Set("user_server_url", "http://127.0.0.1:" + UserConfig.DefaultHttpPort.ToString()); - config.Set("user_send_key", "null"); - config.Set("user_recv_key", "null"); - config.Set("asset_server_url", "http://127.0.0.1:" + AssetConfig.DefaultHttpPort.ToString()); - config.Set("inventory_server_url", "http://127.0.0.1:" + InventoryConfig.DefaultHttpPort.ToString()); - } - - if (DefaultConfig.Configs["RemoteAdmin"] == null) - DefaultConfig.AddConfig("RemoteAdmin"); - config = DefaultConfig.Configs["RemoteAdmin"]; - if (config != null) - { - config.Set("enabled", "false"); - } - - if (DefaultConfig.Configs["Voice"] == null) - DefaultConfig.AddConfig("Voice"); - config = DefaultConfig.Configs["Voice"]; - if (config != null) - { - config.Set("enabled", "false"); - } - return DefaultConfig; - - } - - protected virtual void ReadConfigSettings() - { - m_networkServersInfo = new NetworkServersInfo(); - - IConfig startupConfig = m_config.Configs["Startup"]; - - if (startupConfig != null) - { - m_sandbox = !startupConfig.GetBoolean("gridmode", false); - m_physicsEngine = startupConfig.GetString("physics", "basicphysics"); - m_meshEngineName = startupConfig.GetString("meshing", "ZeroMesher"); - - m_physicalPrim = startupConfig.GetBoolean("physical_prim", true); - - m_see_into_region_from_neighbor = startupConfig.GetBoolean("see_into_this_sim_from_neighbor", true); - - m_storageDll = startupConfig.GetString("storage_plugin", "OpenSim.Data.SQLite.dll"); - if (m_storageDll == "OpenSim.DataStore.MonoSqlite.dll") - { - m_storageDll = "OpenSim.Data.SQLite.dll"; - Console.WriteLine("WARNING: OpenSim.DataStore.MonoSqlite.dll is deprecated. Set storage_plugin to OpenSim.Data.SQLite.dll."); - Thread.Sleep(3000); - } - m_storageConnectionString - = startupConfig.GetString("storage_connection_string", "URI=file:OpenSim.db,version=3"); - m_storagePersistPrimInventories - = startupConfig.GetBoolean("storage_prim_inventories", true); - - m_scriptEngine = startupConfig.GetString("script_engine", "OpenSim.Region.ScriptEngine.DotNetEngine.dll"); - m_assetStorage = startupConfig.GetString("asset_database", "local"); - } - - IConfig standaloneConfig = m_config.Configs["StandAlone"]; - if (standaloneConfig != null) - { - m_standaloneAuthenticate = standaloneConfig.GetBoolean("accounts_authenticate", false); - m_standaloneWelcomeMessage = standaloneConfig.GetString("welcome_message", "Welcome to OpenSim"); - m_standaloneInventoryPlugin = - standaloneConfig.GetString("inventory_plugin", "OpenSim.Data.SQLite.dll"); - m_standaloneInventorySource = - standaloneConfig.GetString("inventory_source",""); - m_standaloneUserPlugin = - standaloneConfig.GetString("userDatabase_plugin", "OpenSim.Data.SQLite.dll"); - m_standaloneUserSource = - standaloneConfig.GetString("user_source",""); - m_standaloneAssetPlugin = - standaloneConfig.GetString("asset_plugin", "OpenSim.Data.SQLite.dll"); - m_standaloneAssetSource = - standaloneConfig.GetString("asset_source",""); - - m_dumpAssetsToFile = standaloneConfig.GetBoolean("dump_assets_to_file", false); - } - - - m_networkServersInfo.loadFromConfiguration(m_config); - - } - - private ManualResetEvent WorldHasComeToAnEnd = new ManualResetEvent(false); - - /// - /// Performs initialisation of the scene, such as loading configuration from disk. - /// - public override void StartUp() - { - // - // Called from app startup (OpenSim.Application) - // - m_log.Info("===================================================================="); - m_log.Info("========================= STARTING OPENSIM ========================="); - m_log.Info("===================================================================="); - m_log.InfoFormat("[OPENSIM MAIN]: Running in background {0} mode", m_sandbox ? "sandbox" : "grid"); - - InternalStartUp(); - - // We are done with startup - m_log.InfoFormat("[OPENSIM MAIN]: Startup complete, serving {0} region{1}", - m_clientServers.Count.ToString(), m_clientServers.Count > 1 ? "s" : ""); - - WorldHasComeToAnEnd.WaitOne(); - m_log.Info("[OPENSIM MAIN]: Shutdown complete, goodbye."); - - Environment.Exit(0); - } - - /// - /// Performs initialisation of the scene, such as loading configuration from disk. - /// - protected void InternalStartUp() - { - m_log.Info("[STARTUP]: Version " + m_version + "\n"); - - m_stats = StatsManager.StartCollectingSimExtraStats(); - - // Do baseclass startup sequence: OpenSim.Region.ClientStack.RegionApplicationBase.StartUp - // TerrainManager, StorageManager, HTTP Server - // This base will call abstract Initialize - base.StartUp(); - - // StandAlone mode? m_sandbox is determined by !startupConfig.GetBoolean("gridmode", false) - if (m_sandbox) - { - LocalInventoryService inventoryService = new LocalInventoryService(); - inventoryService.AddPlugin(m_standaloneInventoryPlugin, m_standaloneInventorySource); - - LocalUserServices userService = - new LocalUserServices(m_networkServersInfo, m_networkServersInfo.DefaultHomeLocX, - m_networkServersInfo.DefaultHomeLocY, inventoryService); - userService.AddPlugin(m_standaloneUserPlugin, m_standaloneUserSource); - - LocalBackEndServices backendService = new LocalBackEndServices(); - - CommunicationsLocal localComms = - new CommunicationsLocal(m_networkServersInfo, m_httpServer, m_assetCache, userService, - inventoryService, backendService, backendService, m_dumpAssetsToFile); - m_commsManager = localComms; - - m_loginService = - new LocalLoginService(userService, m_standaloneWelcomeMessage, localComms, m_networkServersInfo, - m_standaloneAuthenticate); - m_loginService.OnLoginToRegion += backendService.AddNewSession; - - // set up XMLRPC handler for client's initial login request message - m_httpServer.AddXmlRPCHandler("login_to_simulator", m_loginService.XmlRpcLoginMethod); - - // provides the web form login - m_httpServer.AddHTTPHandler("login", m_loginService.ProcessHTMLLogin); - - // Provides the LLSD login - m_httpServer.SetLLSDHandler(m_loginService.LLSDLoginMethod); - - CreateAccount = localComms.doCreate; - } - else - { - // We are in grid mode - m_commsManager = new CommunicationsOGS1(m_networkServersInfo, m_httpServer, m_assetCache); - m_httpServer.AddStreamHandler(new SimStatusHandler()); - } - - proxyUrl = ConfigSource.Configs["Network"].GetString("proxy_url", ""); - proxyOffset = Int32.Parse(ConfigSource.Configs["Network"].GetString("proxy_offset", "0")); - - // Create a ModuleLoader instance - m_moduleLoader = new ModuleLoader(m_config); - - ExtensionNodeList nodes = AddinManager.GetExtensionNodes("/OpenSim/Startup"); - foreach (TypeExtensionNode node in nodes) - { - m_log.InfoFormat("[PLUGINS]: Loading OpenSim application plugin {0}", node.Path); - IApplicationPlugin plugin = (IApplicationPlugin)node.CreateInstance(); - plugin.Initialise(this); - m_plugins.Add(plugin); - } - } - - protected override void Initialize() - { - // - // Called from base.StartUp() - // - - m_httpServerPort = m_networkServersInfo.HttpListenerPort; - - IAssetServer assetServer; - if (m_assetStorage == "grid") - { - assetServer = new GridAssetClient(m_networkServersInfo.AssetURL); - } - else - { - SQLAssetServer sqlAssetServer = new SQLAssetServer(m_standaloneAssetPlugin, m_standaloneAssetSource); - sqlAssetServer.LoadDefaultAssets(); - assetServer = sqlAssetServer; - } - - m_assetCache = new AssetCache(assetServer); - - m_sceneManager.OnRestartSim += handleRestartRegion; - } - - public LLUUID CreateUser(string tempfirstname, string templastname, string tempPasswd, uint regX, uint regY) - { - return m_commsManager.AddUser(tempfirstname,templastname,tempPasswd,regX,regY); - } - - /// - /// Execute the region creation process. This includes setting up scene infrastructure. - /// - /// - /// - /// - public IClientNetworkServer CreateRegion(RegionInfo regionInfo, bool portadd_flag) - { - return CreateRegion(regionInfo, portadd_flag, false); - } - - /// - /// Execute the region creation process. This includes setting up scene infrastructure. - /// - /// - /// - /// - public IClientNetworkServer CreateRegion(RegionInfo regionInfo) - { - return CreateRegion(regionInfo, false, true); - } - - /// - /// Execute the region creation process. This includes setting up scene infrastructure. - /// - /// - /// - /// - /// - public IClientNetworkServer CreateRegion(RegionInfo regionInfo, bool portadd_flag, bool do_post_init) - { - int port = regionInfo.InternalEndPoint.Port; - - // set initial RegionID to originRegionID in RegionInfo. (it needs for loding prims) - regionInfo.originRegionID = regionInfo.RegionID; - - // set initial ServerURI - regionInfo.ServerURI = "http://" + regionInfo.ExternalHostName - + ":" + regionInfo.InternalEndPoint.Port.ToString(); - - regionInfo.HttpPort = m_httpServerPort; - - if ((proxyUrl.Length > 0) && (portadd_flag)) - { - // set proxy url to RegionInfo - regionInfo.proxyUrl = proxyUrl; - Util.XmlRpcCommand(proxyUrl, "AddPort", port, port + proxyOffset, regionInfo.ExternalHostName); - } - - IClientNetworkServer clientServer; - Scene scene = SetupScene(regionInfo, proxyOffset, out clientServer); - - m_log.Info("[MODULES]: Loading Region's modules"); - - List modules = m_moduleLoader.PickupModules(scene, "."); - // This needs to be ahead of the script engine load, so the - // script module can pick up events exposed by a module - m_moduleLoader.InitialiseSharedModules(scene); - - //m_moduleLoader.PickupModules(scene, "ScriptEngines"); - //m_moduleLoader.LoadRegionModules(Path.Combine("ScriptEngines", m_scriptEngine), scene); - - if (string.IsNullOrEmpty(m_scriptEngine)) - { - m_log.Info("[MODULES]: No script engien module specified"); - } - else - { - m_log.Info("[MODULES]: Loading scripting engine modules"); - foreach (string module in m_scriptEngine.Split(',')) - { - string mod = module.Trim(" \t".ToCharArray()); // Clean up name - m_log.Info("[MODULES]: Loading scripting engine: " + mod); - try - { - m_moduleLoader.LoadRegionModules(Path.Combine("ScriptEngines", mod), scene); - } - catch (Exception ex) - { - m_log.Error("[MODULES]: Failed to load script engine: " + ex.ToString()); - } - } - } - - scene.SetModuleInterfaces(); - - //moved these here as the terrain texture has to be created after the modules are initialized - // and has to happen before the region is registered with the grid. - scene.CreateTerrainTexture(true); - - try - { - scene.RegisterRegionWithGrid(); - } - catch (Exception e) - { - m_log.ErrorFormat("[STARTUP]: Registration of region with grid failed, aborting startup - {0}", e); - - // Carrying on now causes a lot of confusion down the line - we need to get the user's attention - System.Environment.Exit(1); - } - - // We need to do this after we've initialized the scripting engines. - scene.StartScripts(); - - scene.loadAllLandObjectsFromStorage(regionInfo.originRegionID); - scene.EventManager.TriggerParcelPrimCountUpdate(); - - m_sceneManager.Add(scene); - - m_clientServers.Add(clientServer); - m_regionData.Add(regionInfo); - clientServer.Start(); - - if (do_post_init) - { - foreach (IRegionModule module in modules) - { - module.PostInitialise(); - } - } - - return clientServer; - } - - protected override StorageManager CreateStorageManager(string connectionstring) - { - return new StorageManager(m_storageDll, connectionstring, m_storagePersistPrimInventories); - } - - protected override Scene CreateScene(RegionInfo regionInfo, StorageManager storageManager, - AgentCircuitManager circuitManager) - { - SceneCommunicationService sceneGridService = new SceneCommunicationService(m_commsManager); - return - new Scene(regionInfo, circuitManager, m_commsManager, sceneGridService, m_assetCache, - storageManager, m_httpServer, - m_moduleLoader, m_dumpAssetsToFile, m_physicalPrim, m_see_into_region_from_neighbor, m_config, - m_version); - - } - - public void handleRestartRegion(RegionInfo whichRegion) - { - m_log.Error("[OPENSIM MAIN]: Got restart signal from SceneManager"); - - // Shutting down the client server - bool foundClientServer = false; - int clientServerElement = 0; - - for (int i = 0; i < m_clientServers.Count; i++) - { - if (m_clientServers[i].HandlesRegion(new Location(whichRegion.RegionHandle))) - { - clientServerElement = i; - foundClientServer = true; - break; - } - } - if (foundClientServer) - { - m_clientServers[clientServerElement].Server.Close(); - m_clientServers.RemoveAt(clientServerElement); - } - - //Removing the region from the sim's database of regions.. - int RegionHandleElement = -1; - for (int i = 0; i < m_regionData.Count; i++) - { - if (whichRegion.RegionHandle == m_regionData[i].RegionHandle) - { - RegionHandleElement = i; - } - } - if (RegionHandleElement >= 0) - { - m_regionData.RemoveAt(RegionHandleElement); - } - - CreateRegion(whichRegion, true); - } - - # region Setup methods - - protected override PhysicsScene GetPhysicsScene() - { - return GetPhysicsScene(m_physicsEngine, m_meshEngineName, m_config); - } - - /// - /// Handler to supply the current status of this sim - /// - /// Currently this is always OK if the simulator is still listening for connections on its HTTP service - /// - protected class SimStatusHandler : IStreamedRequestHandler - { - public byte[] Handle(string path, Stream request, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) - { - return Encoding.UTF8.GetBytes("OK"); - } - - public string ContentType - { - get { return "text/plain"; } - } - - public string HttpMethod - { - get { return "GET"; } - } - - public string Path - { - get { return "/simstatus/"; } - } - } - - #endregion - - /// - /// Performs any last-minute sanity checking and shuts down the region server - /// - public override void Shutdown() - { - if (proxyUrl.Length > 0) - { - Util.XmlRpcCommand(proxyUrl, "Stop"); - } - - m_log.Info("[SHUTDOWN]: Closing all threads"); - m_log.Info("[SHUTDOWN]: Killing listener thread"); - m_log.Info("[SHUTDOWN]: Killing clients"); - // TODO: implement this - m_log.Info("[SHUTDOWN]: Closing console and terminating"); - - m_sceneManager.Close(); - - WorldHasComeToAnEnd.Set(); - - base.Shutdown(); - } - - /// - /// Get the start time and up time of Region server - /// - /// The first out parameter describing when the Region server started - /// The second out parameter describing how long the Region server has run - public void GetRunTime(out string starttime, out string uptime) - { - starttime = m_startuptime.ToString(); - uptime = (DateTime.Now - m_startuptime).ToString(); - } - - /// - /// Get the number of the avatars in the Region server - /// - /// The first out parameter describing the number of all the avatars in the Region server - public void GetAvatarNumber(out int usernum) - { - usernum = m_sceneManager.GetCurrentSceneAvatars().Count; - } - - /// - /// Get the number of regions - /// - /// The first out parameter describing the number of regions - public void GetRegionNumber(out int regionnum) - { - regionnum = m_sceneManager.Scenes.Count; - } - } -} diff --git a/OpenSim/Region/Application/OpenSimMainConsole.cs b/OpenSim/Region/Application/OpenSimMainConsole.cs deleted file mode 100644 index 467db14..0000000 --- a/OpenSim/Region/Application/OpenSimMainConsole.cs +++ /dev/null @@ -1,679 +0,0 @@ -/* - * 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 OpenSim 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.Collections; -using System.Collections.Generic; -using System.IO; -using System.Net; -using System.Reflection; -using System.Threading; -using libsecondlife; -using log4net; -using Nini.Config; -using OpenSim.Framework; -using OpenSim.Framework.Console; -using OpenSim.Framework.Statistics; -using OpenSim.Region.Environment.Interfaces; -using OpenSim.Region.Environment.Scenes; -using Timer=System.Timers.Timer; - -namespace OpenSim -{ - public delegate void ConsoleCommand(string[] comParams); - - public class OpenSimMainConsole : OpenSimMain, conscmd_callback - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - protected string m_startupCommandsFile; - protected string m_shutdownCommandsFile; - - private string m_timedScript = "disabled"; - private Timer m_scriptTimer; - - public OpenSimMainConsole(IConfigSource configSource) - : base(configSource) - { - } - - protected override void ReadConfigSettings() - { - IConfig startupConfig = m_config.Configs["Startup"]; - - if (startupConfig != null) - { - m_startupCommandsFile = startupConfig.GetString("startup_console_commands_file", String.Empty); - m_shutdownCommandsFile = startupConfig.GetString("shutdown_console_commands_file", String.Empty); - - m_timedScript = startupConfig.GetString("timer_Script", "disabled"); - } - base.ReadConfigSettings(); - } - - /// - /// Performs initialisation of the scene, such as loading configuration from disk. - /// - public override void StartUp() - { - // - // Called from app startup (OpenSim.Application) - // - - m_log.Info("===================================================================="); - m_log.Info("========================= STARTING OPENSIM ========================="); - m_log.Info("===================================================================="); - m_log.InfoFormat("[OPENSIM MAIN]: Running in {0} mode", (m_sandbox ? "sandbox" : "grid")); - - m_console = CreateConsole(); - MainConsole.Instance = m_console; - InternalStartUp(); - - //Run Startup Commands - if (m_startupCommandsFile != String.Empty) - { - RunCommandScript(m_startupCommandsFile); - } - else - { - m_log.Info("[STARTUP]: No startup command script specified. Moving on..."); - } - - // Start timer script (run a script every xx seconds) - if (m_timedScript != "disabled") - { - m_scriptTimer = new Timer(); - m_scriptTimer.Enabled = true; - m_scriptTimer.Interval = 1200 * 1000; - m_scriptTimer.Elapsed += RunAutoTimerScript; - } - - PrintFileToConsole("startuplogo.txt"); - } - - protected ConsoleBase CreateConsole() - { - return new ConsoleBase("Region", this); - } - - private void RunAutoTimerScript(object sender, EventArgs e) - { - if (m_timedScript != "disabled") - { - RunCommandScript(m_timedScript); - } - } - - #region Console Commands - - /// - /// - /// - /// - private void RunCommandScript(string fileName) - { - m_log.Info("[COMMANDFILE]: Running " + fileName); - if (File.Exists(fileName)) - { - StreamReader readFile = File.OpenText(fileName); - string currentCommand; - while ((currentCommand = readFile.ReadLine()) != null) - { - if (currentCommand != String.Empty) - { - m_log.Info("[COMMANDFILE]: Running '" + currentCommand + "'"); - m_console.RunCommand(currentCommand); - } - } - } - else - { - m_log.Error("[COMMANDFILE]: Command script missing. Can not run commands"); - } - } - - private static void PrintFileToConsole(string fileName) - { - if (File.Exists(fileName)) - { - StreamReader readFile = File.OpenText(fileName); - string currentLine; - while ((currentLine = readFile.ReadLine()) != null) - { - m_log.Info("[!]" + currentLine); - } - } - } - - - /// - /// Runs commands issued by the server console from the operator - /// - /// The first argument of the parameter (the command) - /// Additional arguments passed to the command - public override void RunCmd(string command, string[] cmdparams) - { - base.RunCmd(command, cmdparams); - - switch (command) - { - case "clear-assets": - m_assetCache.Clear(); - break; - - case "set-time": - m_sceneManager.SetCurrentSceneTimePhase(Convert.ToInt32(cmdparams[0])); - break; - - case "force-update": - m_console.Notice("Updating all clients"); - m_sceneManager.ForceCurrentSceneClientUpdate(); - break; - - case "edit-scale": - if (cmdparams.Length == 4) - { - m_sceneManager.HandleEditCommandOnCurrentScene(cmdparams); - } - break; - - case "debug": - if (cmdparams.Length > 0) - { - Debug(cmdparams); - } - break; - - case "scene-debug": - if (cmdparams.Length == 3) - { - if (m_sceneManager.CurrentScene == null) - { - m_console.Error("CONSOLE", "Please use 'change-region ' first"); - } - else - { - m_sceneManager.CurrentScene.SetSceneCoreDebug(!Convert.ToBoolean(cmdparams[0]), !Convert.ToBoolean(cmdparams[1]), !Convert.ToBoolean(cmdparams[2])); - } - } - else - { - m_console.Error("scene-debug (where inside <> is true/false)"); - } - break; - - case "help": - m_console.Notice("alert - send alert to a designated user or all users."); - m_console.Notice(" alert [First] [Last] [Message] - send an alert to a user. Case sensitive."); - m_console.Notice(" alert general [Message] - send an alert to all users."); - m_console.Notice("backup - trigger a simulator backup"); - m_console.Notice("clear-assets - clear asset cache"); - m_console.Notice("create-region - creates a new region"); - m_console.Notice("create user - adds a new user."); - m_console.Notice("change-region [name] - sets the region that many of these commands affect."); - m_console.Notice("command-script [filename] - Execute command in a file."); - m_console.Notice("debug - debugging commands"); - m_console.Notice(" packet 0..255 - print incoming/outgoing packets (0=off)"); - m_console.Notice("scene-debug [scripting] [collision] [physics] - Enable/Disable debug stuff, each can be True/False"); - m_console.Notice("edit-scale [prim name] [x] [y] [z] - resize given prim"); - m_console.Notice("export-map [filename] - save image of world map"); - m_console.Notice("force-update - force an update of prims in the scene"); - m_console.Notice("load-xml [filename] - load prims from XML (DEPRECATED)"); - m_console.Notice("load-xml2 [filename] - load prims from XML using version 2 format"); - m_console.Notice("restart - disconnects all clients and restarts the sims in the instance."); - m_console.Notice("remove-region [name] - remove a region"); - m_console.Notice("save-xml [filename] - save prims to XML (DEPRECATED)"); - m_console.Notice("save-xml2 [filename] - save prims to XML using version 2 format"); - m_console.Notice("script - manually trigger scripts? or script commands?"); - m_console.Notice("set-time [x] - set the current scene time phase"); - m_console.Notice("show assets - show state of asset cache."); - m_console.Notice("show users - show info about connected users."); - m_console.Notice("show modules - shows info about loaded modules."); - m_console.Notice("show regions - show running region information."); - m_console.Notice("threads - list threads"); - m_console.Notice("config set section field value - set a config value"); - m_console.Notice("config get section field - get a config value"); - m_console.Notice("config save - save OpenSim.ini"); - m_console.Notice("terrain help - show help for terrain commands."); - break; - - case "threads": -// m_console.Notice("THREAD", Process.GetCurrentProcess().Threads.Count + " threads running:"); -// int _tc = 0; - -// foreach (ProcessThread pt in Process.GetCurrentProcess().Threads) -// { -// _tc++; -// m_console.Notice("THREAD", _tc + ": ID: " + pt.Id + ", Started: " + pt.StartTime.ToString() + ", CPU time: " + pt.TotalProcessorTime + ", Pri: " + pt.BasePriority.ToString() + ", State: " + pt.ThreadState.ToString()); -// } - - List threads = ThreadTracker.GetThreads(); - if (threads == null) - { - m_console.Notice("THREAD", "Thread tracking is only enabled in DEBUG mode."); - } - else - { - int _tc = 0; - m_console.Notice("THREAD", threads.Count + " threads are being tracked:"); - foreach (Thread t in threads) - { - _tc++; - m_console.Notice("THREAD", _tc + ": ID: " + t.ManagedThreadId.ToString() + ", Name: " + t.Name + ", Alive: " + t.IsAlive.ToString() + ", Pri: " + t.Priority.ToString() + ", State: " + t.ThreadState.ToString()); - } - } - - break; - case "save-xml": - m_log.Error("[CONSOLE]: PLEASE NOTE, save-xml is DEPRECATED and may be REMOVED soon. If you are using this and there is some reason you can't use save-xml2, please file a mantis detailing the reason."); - - if (cmdparams.Length > 0) - { - m_sceneManager.SaveCurrentSceneToXml(cmdparams[0]); - } - else - { - m_sceneManager.SaveCurrentSceneToXml(DEFAULT_PRIM_BACKUP_FILENAME); - } - break; - - case "load-xml": - m_log.Error("[CONSOLE]: PLEASE NOTE, load-xml is DEPRECATED and may be REMOVED soon. If you are using this and there is some reason you can't use load-xml2, please file a mantis detailing the reason."); - - LLVector3 loadOffset = new LLVector3(0, 0, 0); - if (cmdparams.Length > 0) - { - bool generateNewIDS = false; - if (cmdparams.Length > 1) - { - if (cmdparams[1] == "-newUID") - { - generateNewIDS = true; - } - if (cmdparams.Length > 2) - { - loadOffset.X = (float) Convert.ToDecimal(cmdparams[2]); - if (cmdparams.Length > 3) - { - loadOffset.Y = (float) Convert.ToDecimal(cmdparams[3]); - } - if (cmdparams.Length > 4) - { - loadOffset.Z = (float) Convert.ToDecimal(cmdparams[4]); - } - m_console.Error("loadOffsets = <" + loadOffset.X + "," + loadOffset.Y + "," + - loadOffset.Z + ">"); - } - } - m_sceneManager.LoadCurrentSceneFromXml(cmdparams[0], generateNewIDS, loadOffset); - } - else - { - m_sceneManager.LoadCurrentSceneFromXml(DEFAULT_PRIM_BACKUP_FILENAME, false, loadOffset); - } - break; - - case "save-xml2": - if (cmdparams.Length > 0) - { - m_sceneManager.SaveCurrentSceneToXml2(cmdparams[0]); - } - else - { - m_sceneManager.SaveCurrentSceneToXml2(DEFAULT_PRIM_BACKUP_FILENAME); - } - break; - - case "load-xml2": - if (cmdparams.Length > 0) - { - m_sceneManager.LoadCurrentSceneFromXml2(cmdparams[0]); - } - else - { - m_sceneManager.LoadCurrentSceneFromXml2(DEFAULT_PRIM_BACKUP_FILENAME); - } - break; - - case "load-oar": - m_log.Error("[CONSOLE]: Don't use me - I haven't yet been sufficiently implemented!"); - - if (cmdparams.Length > 0) - { - m_sceneManager.LoadArchiveToCurrentScene(cmdparams[0]); - } - else - { - m_sceneManager.LoadArchiveToCurrentScene(DEFAULT_OAR_BACKUP_FILENAME); - } - break; - - case "save-oar": - m_log.Error("[CONSOLE]: Don't use me - I haven't yet been sufficiently implemented!"); - - if (cmdparams.Length > 0) - { - m_sceneManager.SaveCurrentSceneToArchive(cmdparams[0]); - } - else - { - m_sceneManager.SaveCurrentSceneToArchive(DEFAULT_OAR_BACKUP_FILENAME); - } - break; - - case "plugin": - m_sceneManager.SendCommandToPluginModules(cmdparams); - break; - - case "command-script": - if (cmdparams.Length > 0) - { - RunCommandScript(cmdparams[0]); - } - break; - - case "backup": - m_sceneManager.BackupCurrentScene(); - break; - - case "alert": - m_sceneManager.HandleAlertCommandOnCurrentScene(cmdparams); - break; - - case "create": - CreateAccount(cmdparams); - break; - - case "create-region": - CreateRegion(new RegionInfo(cmdparams[0], "Regions/" + cmdparams[1],false), true); - break; - case "remove-region": - string regName = CombineParams(cmdparams, 0); - - Scene killScene; - if (m_sceneManager.TryGetScene(regName, out killScene)) - { - // only need to check this if we are not at the - // root level - if ((m_sceneManager.CurrentScene != null) && - (m_sceneManager.CurrentScene.RegionInfo.RegionID == killScene.RegionInfo.RegionID)) - { - m_sceneManager.TrySetCurrentScene(".."); - } - m_regionData.Remove(killScene.RegionInfo); - m_sceneManager.CloseScene(killScene); - } - break; - - case "restart": - m_sceneManager.RestartCurrentScene(); - break; - - case "change-region": - if (cmdparams.Length > 0) - { - string regionName = CombineParams(cmdparams, 0); - - if (!m_sceneManager.TrySetCurrentScene(regionName)) - { - m_console.Error("Couldn't set current region to: " + regionName); - } - } - - if (m_sceneManager.CurrentScene == null) - { - m_console.Error("CONSOLE", "Currently at Root level. To change region please use 'change-region '"); - } - else - { - m_console.Error("CONSOLE", "Current Region: " + m_sceneManager.CurrentScene.RegionInfo.RegionName + - ". To change region please use 'change-region '"); - } - - break; - - case "export-map": - if (cmdparams.Length > 0) - { - m_sceneManager.CurrentOrFirstScene.ExportWorldMap(cmdparams[0]); - } - else - { - m_sceneManager.CurrentOrFirstScene.ExportWorldMap("exportmap.jpg"); - } - break; - - case "config": - string n = command.ToUpper(); - if (cmdparams.Length > 0) - { - switch (cmdparams[0].ToLower()) - { - case "set": - if (cmdparams.Length < 4) - { - m_console.Error(n, "SYNTAX: " + n + " SET SECTION KEY VALUE"); - m_console.Error(n, "EXAMPLE: " + n + " SET ScriptEngine.DotNetEngine NumberOfScriptThreads 5"); - } - else - { - IConfig c = DefaultConfig().Configs[cmdparams[1]]; - if (c == null) - c = DefaultConfig().AddConfig(cmdparams[1]); - string _value = String.Join(" ", cmdparams, 3, cmdparams.Length - 3); - c.Set(cmdparams[2], _value); - m_config.Merge(c.ConfigSource); - - m_console.Error(n, n + " " + n + " " + cmdparams[1] + " " + cmdparams[2] + " " + - _value); - } - break; - case "get": - if (cmdparams.Length < 3) - { - m_console.Error(n, "SYNTAX: " + n + " GET SECTION KEY"); - m_console.Error(n, "EXAMPLE: " + n + " GET ScriptEngine.DotNetEngine NumberOfScriptThreads"); - } - else - { - IConfig c = DefaultConfig().Configs[cmdparams[1]]; - if (c == null) - { - m_console.Notice(n, "Section \"" + cmdparams[1] + "\" does not exist."); - break; - } - else - { - m_console.Notice(n + " GET " + cmdparams[1] + " " + cmdparams[2] + ": " + - c.GetString(cmdparams[2])); - } - } - - break; - case "save": - m_console.Notice("Saving configuration file: " + Application.iniFilePath); - m_config.Save(Application.iniFilePath); - break; - } - } - break; - case "modules": - if (cmdparams.Length > 0) - { - switch (cmdparams[0].ToLower()) - { - case "list": - foreach (IRegionModule irm in m_moduleLoader.GetLoadedSharedModules) - { - m_console.Notice("Shared region module: " + irm.Name); - } - break; - case "unload": - if (cmdparams.Length > 1) - { - foreach (IRegionModule rm in new ArrayList(m_moduleLoader.GetLoadedSharedModules)) - { - if (rm.Name.ToLower() == cmdparams[1].ToLower()) - { - m_console.Notice("Unloading module: " + rm.Name); - m_moduleLoader.UnloadModule(rm); - } - } - } - break; - case "load": - if (cmdparams.Length > 1) - { - foreach (Scene s in new ArrayList(m_sceneManager.Scenes)) - { - - m_console.Notice("Loading module: " + cmdparams[1]); - m_moduleLoader.LoadRegionModules(cmdparams[1], s); - } - } - break; - } - } - - break; - default: - string[] tmpPluginArgs = new string[cmdparams.Length + 1]; - cmdparams.CopyTo(tmpPluginArgs, 1); - tmpPluginArgs[0] = command; - - m_sceneManager.SendCommandToPluginModules(tmpPluginArgs); - break; - } - } - - public void Debug(string[] args) - { - switch (args[0]) - { - case "packet": - if (args.Length > 1) - { - int newDebug; - if (int.TryParse(args[1], out newDebug)) - { - m_sceneManager.SetDebugPacketOnCurrentScene(newDebug); - } - else - { - m_console.Error("packet debug should be 0..2"); - } - m_console.Notice("New packet debug: " + newDebug.ToString()); - } - - break; - default: - m_console.Error("Unknown debug"); - break; - } - } - - // see BaseOpenSimServer - public override void Show(string ShowWhat) - { - base.Show(ShowWhat); - - switch (ShowWhat) - { - case "assets": - m_assetCache.ShowState(); - break; - - case "users": - IList agents = m_sceneManager.GetCurrentSceneAvatars(); - - m_console.Notice(String.Format("\nAgents connected: {0}\n", agents.Count)); - - m_console.Notice( - String.Format("{0,-16}{1,-16}{2,-37}{3,-16}", "Firstname", "Lastname", - "Agent ID","Region")); - - foreach (ScenePresence presence in agents) - { - RegionInfo regionInfo = m_sceneManager.GetRegionInfo(presence.RegionHandle); - string regionName; - System.Net.EndPoint ep = null; - - if (regionInfo == null) - { - regionName = "Unresolvable"; - } - else - { - regionName = regionInfo.RegionName; - } - - m_console.Notice( - String.Format( - "{0,-16}{1,-16}{2,-37}{3,-16}", - presence.Firstname, - presence.Lastname, - presence.UUID, - regionName)); - } - - m_console.Notice(""); - break; - - case "modules": - m_console.Notice("The currently loaded shared modules are:"); - foreach (IRegionModule module in m_moduleLoader.GetLoadedSharedModules) - { - m_console.Notice("Shared Module: " + module.Name); - } - break; - - case "regions": - m_sceneManager.ForEachScene( - delegate(Scene scene) - { - m_console.Notice("Region Name: " + scene.RegionInfo.RegionName + " , Region XLoc: " + - scene.RegionInfo.RegionLocX + " , Region YLoc: " + - scene.RegionInfo.RegionLocY); - }); - break; - } - } - - private static string CombineParams(string[] commandParams, int pos) - { - string result = String.Empty; - for (int i = pos; i < commandParams.Length; i++) - { - result += commandParams[i] + " "; - } - result = result.TrimEnd(' '); - return result; - } - - #endregion - } -} diff --git a/OpenSim/Tools/Export/OpenSimExport.cs b/OpenSim/Tools/Export/OpenSimExport.cs index 4891ea7..1e7db51 100644 --- a/OpenSim/Tools/Export/OpenSimExport.cs +++ b/OpenSim/Tools/Export/OpenSimExport.cs @@ -102,7 +102,7 @@ namespace OpenSimExport { // no default config files, so set default values, and save it Console.WriteLine("We didn't find a config!"); - config.Merge(OpenSimMain.DefaultConfig()); + config.Merge(OpenSimBase.DefaultConfig()); config.Merge(configSource); } diff --git a/ThirdParty/3Di/LoadBalancer/LoadBalancerPlugin.cs b/ThirdParty/3Di/LoadBalancer/LoadBalancerPlugin.cs index bdddbbb..9a6c05b 100644 --- a/ThirdParty/3Di/LoadBalancer/LoadBalancerPlugin.cs +++ b/ThirdParty/3Di/LoadBalancer/LoadBalancerPlugin.cs @@ -67,13 +67,13 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer private SceneManager sceneManager; private string[] sceneURL; private string serializeDir; - private OpenSimMain simMain; + private OpenSimBase simMain; private TcpClient[] tcpClientList; private List m_clientServers; #region IApplicationPlugin Members - public void Initialise(OpenSimMain openSim) + public void Initialise(OpenSimBase openSim) { m_log.Info("[BALANCER] " + "Entering Initialize()"); diff --git a/ThirdParty/3Di/RegionProxy/RegionProxyPlugin.cs b/ThirdParty/3Di/RegionProxy/RegionProxyPlugin.cs index 16470de..c9711c3 100644 --- a/ThirdParty/3Di/RegionProxy/RegionProxyPlugin.cs +++ b/ThirdParty/3Di/RegionProxy/RegionProxyPlugin.cs @@ -69,7 +69,7 @@ namespace OpenSim.ApplicationPlugins.RegionProxy #region IApplicationPlugin Members - public void Initialise(OpenSimMain openSim) + public void Initialise(OpenSimBase openSim) { m_log.Info("Starting proxy"); string proxyURL = openSim.ConfigSource.Configs["Network"].GetString("proxy_url", ""); -- cgit v1.1