* Refactor: Split opensim background server into a separate class
parent
65db9eadef
commit
8e1d338656
|
@ -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");
|
||||
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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.
|
||||
/// </remarks>
|
||||
public override void Initialise(OpenSimMain openSim)
|
||||
public override void Initialise(OpenSimBase openSim)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
|
@ -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
|
|||
/// <summary>
|
||||
/// OpenSimMain application
|
||||
/// </summary>
|
||||
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.
|
||||
/// </remarks>
|
||||
public virtual void Initialise(OpenSimMain openSim)
|
||||
public virtual void Initialise(OpenSimBase openSim)
|
||||
{
|
||||
RequestID = "0";
|
||||
MsgID = RequestID;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace OpenSim
|
|||
[TypeExtensionPoint("/OpenSim/Startup")]
|
||||
public interface IApplicationPlugin
|
||||
{
|
||||
void Initialise(OpenSimMain openSim);
|
||||
void Initialise(OpenSimBase openSim);
|
||||
void Close();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,10 @@ namespace OpenSim
|
|||
{
|
||||
public delegate void ConsoleCommand(string[] comParams);
|
||||
|
||||
public class OpenSimMainConsole : OpenSimMain, conscmd_callback
|
||||
/// <summary>
|
||||
/// Interactive OpenSim region server
|
||||
/// </summary>
|
||||
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)
|
||||
{
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Consoleless OpenSim region server
|
||||
/// </summary>
|
||||
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)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs initialisation of the scene, such as loading configuration from disk.
|
||||
/// </summary>
|
||||
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();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs any last-minute sanity checking and shuts down the region server
|
||||
/// </summary>
|
||||
public override void Shutdown()
|
||||
{
|
||||
WorldHasComeToAnEnd.Set();
|
||||
|
||||
base.Shutdown();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -50,7 +50,10 @@ using OpenSim.Region.Physics.Manager;
|
|||
|
||||
namespace OpenSim
|
||||
{
|
||||
public class OpenSimMain : RegionApplicationBase
|
||||
/// <summary>
|
||||
/// Common OpenSim region service code
|
||||
/// </summary>
|
||||
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);
|
||||
|
||||
/// <summary>
|
||||
/// Performs initialisation of the scene, such as loading configuration from disk.
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -692,8 +666,6 @@ namespace OpenSim
|
|||
|
||||
m_sceneManager.Close();
|
||||
|
||||
WorldHasComeToAnEnd.Set();
|
||||
|
||||
base.Shutdown();
|
||||
}
|
||||
|
||||
|
@ -727,3 +699,4 @@ namespace OpenSim
|
|||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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<IClientNetworkServer> m_clientServers;
|
||||
|
||||
#region IApplicationPlugin Members
|
||||
|
||||
public void Initialise(OpenSimMain openSim)
|
||||
public void Initialise(OpenSimBase openSim)
|
||||
{
|
||||
m_log.Info("[BALANCER] " + "Entering Initialize()");
|
||||
|
||||
|
|
|
@ -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", "");
|
||||
|
|
Loading…
Reference in New Issue