diff --git a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs index dc4d1db5f2..8dde28ca09 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 c4365961af..232fd09f20 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 aeb91a9682..9d68225642 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 ffabb2a5ec..e4bd54466e 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 9aa885f825..72fdf1025f 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 30f8da8b5b..7ca4383b9a 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/OpenSimMainConsole.cs b/OpenSim/Region/Application/OpenSim.cs similarity index 99% rename from OpenSim/Region/Application/OpenSimMainConsole.cs rename to OpenSim/Region/Application/OpenSim.cs index 467db14877..1bed036436 100644 --- a/OpenSim/Region/Application/OpenSimMainConsole.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -46,7 +46,10 @@ namespace OpenSim { public delegate void ConsoleCommand(string[] comParams); - public class OpenSimMainConsole : OpenSimMain, conscmd_callback + /// + /// Interactive OpenSim region server + /// + public class OpenSim : OpenSimBase, conscmd_callback { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -56,8 +59,7 @@ namespace OpenSim private string m_timedScript = "disabled"; private Timer m_scriptTimer; - public OpenSimMainConsole(IConfigSource configSource) - : base(configSource) + public OpenSim(IConfigSource configSource) : base(configSource) { } @@ -620,7 +622,6 @@ namespace OpenSim { RegionInfo regionInfo = m_sceneManager.GetRegionInfo(presence.RegionHandle); string regionName; - System.Net.EndPoint ep = null; if (regionInfo == null) { diff --git a/OpenSim/Region/Application/OpenSimBackground.cs b/OpenSim/Region/Application/OpenSimBackground.cs new file mode 100644 index 0000000000..0c3a0a33ec --- /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/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimBase.cs similarity index 95% rename from OpenSim/Region/Application/OpenSimMain.cs rename to OpenSim/Region/Application/OpenSimBase.cs index 03dbf781ac..468881e914 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -50,7 +50,10 @@ using OpenSim.Region.Physics.Manager; namespace OpenSim { - public class OpenSimMain : RegionApplicationBase + /// + /// Common OpenSim region service code + /// + public class OpenSimBase : RegionApplicationBase { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -139,7 +142,7 @@ namespace OpenSim set { m_moduleLoader = value; } } - public OpenSimMain(IConfigSource configSource) + public OpenSimBase(IConfigSource configSource) : base() { IConfig startupConfig = configSource.Configs["Startup"]; @@ -321,36 +324,7 @@ namespace OpenSim 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); } /// @@ -692,8 +666,6 @@ namespace OpenSim m_sceneManager.Close(); - WorldHasComeToAnEnd.Set(); - base.Shutdown(); } @@ -727,3 +699,4 @@ namespace OpenSim } } } + diff --git a/OpenSim/Tools/Export/OpenSimExport.cs b/OpenSim/Tools/Export/OpenSimExport.cs index 4891ea7d5e..1e7db51f7c 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 bdddbbb0eb..9a6c05bf32 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 16470de0c4..c9711c3dc8 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", "");