aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clarke Casey2008-06-01 01:01:16 +0000
committerJustin Clarke Casey2008-06-01 01:01:16 +0000
commit8e1d3386561f263646c10c875aa00af4b3c9f815 (patch)
tree3fc89893ecdd75b0be7283dd0b4a2b9376b59964 /OpenSim
parent* Updates permission module so that GenericCommunicationPermission returns tr... (diff)
downloadopensim-SC_OLD-8e1d3386561f263646c10c875aa00af4b3c9f815.zip
opensim-SC_OLD-8e1d3386561f263646c10c875aa00af4b3c9f815.tar.gz
opensim-SC_OLD-8e1d3386561f263646c10c875aa00af4b3c9f815.tar.bz2
opensim-SC_OLD-8e1d3386561f263646c10c875aa00af4b3c9f815.tar.xz
* Refactor: Split opensim background server into a separate class
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs4
-rw-r--r--OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs4
-rw-r--r--OpenSim/ApplicationPlugins/Rest/Regions/RestRegionPlugin.cs2
-rw-r--r--OpenSim/ApplicationPlugins/Rest/RestPlugin.cs6
-rw-r--r--OpenSim/Region/Application/Application.cs4
-rw-r--r--OpenSim/Region/Application/IApplicationPlugin.cs2
-rw-r--r--OpenSim/Region/Application/OpenSim.cs (renamed from OpenSim/Region/Application/OpenSimMainConsole.cs)9
-rw-r--r--OpenSim/Region/Application/OpenSimBackground.cs80
-rw-r--r--OpenSim/Region/Application/OpenSimBase.cs (renamed from OpenSim/Region/Application/OpenSimMain.cs)39
-rw-r--r--OpenSim/Tools/Export/OpenSimExport.cs2
10 files changed, 103 insertions, 49 deletions
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
46 46
47 #region IApplicationPlugin Members 47 #region IApplicationPlugin Members
48 48
49 public void Initialise(OpenSimMain openSim) 49 public void Initialise(OpenSimBase openSim)
50 { 50 {
51 m_log.Info("[LOADREGIONS]: Load Regions addin being initialised"); 51 m_log.Info("[LOADREGIONS]: Load Regions addin being initialised");
52 52
@@ -84,7 +84,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
84 84
85 #endregion 85 #endregion
86 86
87 public void LoadRegionFromConfig(OpenSimMain openSim, ulong regionhandle) 87 public void LoadRegionFromConfig(OpenSimBase openSim, ulong regionhandle)
88 { 88 {
89 m_log.Info("[LOADREGIONS]: Load Regions addin being initialised"); 89 m_log.Info("[LOADREGIONS]: Load Regions addin being initialised");
90 90
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
50 { 50 {
51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52 52
53 private OpenSimMain m_app; 53 private OpenSimBase m_app;
54 private BaseHttpServer m_httpd; 54 private BaseHttpServer m_httpd;
55 private string requiredPassword = String.Empty; 55 private string requiredPassword = String.Empty;
56 56
57 public void Initialise(OpenSimMain openSim) 57 public void Initialise(OpenSimBase openSim)
58 { 58 {
59 try 59 try
60 { 60 {
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
85 /// Note that entries MUST be added to the active configuration files before 85 /// Note that entries MUST be added to the active configuration files before
86 /// the plugin can be enabled. 86 /// the plugin can be enabled.
87 /// </remarks> 87 /// </remarks>
88 public override void Initialise(OpenSimMain openSim) 88 public override void Initialise(OpenSimBase openSim)
89 { 89 {
90 try 90 try
91 { 91 {
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
60 60
61 private IConfig _config; // Configuration source: Rest Plugins 61 private IConfig _config; // Configuration source: Rest Plugins
62 private IConfig _pluginConfig; // Configuration source: Plugin specific 62 private IConfig _pluginConfig; // Configuration source: Plugin specific
63 private OpenSimMain _app; // The 'server' 63 private OpenSimBase _app; // The 'server'
64 private BaseHttpServer _httpd; // The server's RPC interface 64 private BaseHttpServer _httpd; // The server's RPC interface
65 private string _prefix; // URL prefix below 65 private string _prefix; // URL prefix below
66 // which all REST URLs 66 // which all REST URLs
@@ -114,7 +114,7 @@ namespace OpenSim.ApplicationPlugins.Rest
114 /// <summary> 114 /// <summary>
115 /// OpenSimMain application 115 /// OpenSimMain application
116 /// </summary> 116 /// </summary>
117 public OpenSimMain App 117 public OpenSimBase App
118 { 118 {
119 get { return _app; } 119 get { return _app; }
120 } 120 }
@@ -196,7 +196,7 @@ namespace OpenSim.ApplicationPlugins.Rest
196 /// Note that entries MUST be added to the active configuration files before 196 /// Note that entries MUST be added to the active configuration files before
197 /// the plugin can be enabled. 197 /// the plugin can be enabled.
198 /// </remarks> 198 /// </remarks>
199 public virtual void Initialise(OpenSimMain openSim) 199 public virtual void Initialise(OpenSimBase openSim)
200 { 200 {
201 RequestID = "0"; 201 RequestID = "0";
202 MsgID = RequestID; 202 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
82 82
83 if (background) 83 if (background)
84 { 84 {
85 OpenSimMain sim = new OpenSimMain(configSource); 85 OpenSimBase sim = new OpenSimBackground(configSource);
86 sim.StartUp(); 86 sim.StartUp();
87 } 87 }
88 else 88 else
89 { 89 {
90 OpenSimMain sim = new OpenSimMainConsole(configSource); 90 OpenSimBase sim = new OpenSim(configSource);
91 sim.StartUp(); 91 sim.StartUp();
92 92
93 while (true) 93 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
34 [TypeExtensionPoint("/OpenSim/Startup")] 34 [TypeExtensionPoint("/OpenSim/Startup")]
35 public interface IApplicationPlugin 35 public interface IApplicationPlugin
36 { 36 {
37 void Initialise(OpenSimMain openSim); 37 void Initialise(OpenSimBase openSim);
38 void Close(); 38 void Close();
39 } 39 }
40} 40}
diff --git a/OpenSim/Region/Application/OpenSimMainConsole.cs b/OpenSim/Region/Application/OpenSim.cs
index 467db14..1bed036 100644
--- a/OpenSim/Region/Application/OpenSimMainConsole.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -46,7 +46,10 @@ namespace OpenSim
46{ 46{
47 public delegate void ConsoleCommand(string[] comParams); 47 public delegate void ConsoleCommand(string[] comParams);
48 48
49 public class OpenSimMainConsole : OpenSimMain, conscmd_callback 49 /// <summary>
50 /// Interactive OpenSim region server
51 /// </summary>
52 public class OpenSim : OpenSimBase, conscmd_callback
50 { 53 {
51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52 55
@@ -56,8 +59,7 @@ namespace OpenSim
56 private string m_timedScript = "disabled"; 59 private string m_timedScript = "disabled";
57 private Timer m_scriptTimer; 60 private Timer m_scriptTimer;
58 61
59 public OpenSimMainConsole(IConfigSource configSource) 62 public OpenSim(IConfigSource configSource) : base(configSource)
60 : base(configSource)
61 { 63 {
62 } 64 }
63 65
@@ -620,7 +622,6 @@ namespace OpenSim
620 { 622 {
621 RegionInfo regionInfo = m_sceneManager.GetRegionInfo(presence.RegionHandle); 623 RegionInfo regionInfo = m_sceneManager.GetRegionInfo(presence.RegionHandle);
622 string regionName; 624 string regionName;
623 System.Net.EndPoint ep = null;
624 625
625 if (regionInfo == null) 626 if (regionInfo == null)
626 { 627 {
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 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System.Reflection;
29using System.Threading;
30using log4net;
31using Nini.Config;
32
33namespace OpenSim
34{
35 /// <summary>
36 /// Consoleless OpenSim region server
37 /// </summary>
38 public class OpenSimBackground : OpenSimBase
39 {
40 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
41
42 private ManualResetEvent WorldHasComeToAnEnd = new ManualResetEvent(false);
43
44 public OpenSimBackground(IConfigSource configSource) : base(configSource)
45 {
46 }
47
48 /// <summary>
49 /// Performs initialisation of the scene, such as loading configuration from disk.
50 /// </summary>
51 public override void StartUp()
52 {
53 //
54 // Called from app startup (OpenSim.Application)
55 //
56 m_log.Info("====================================================================");
57 m_log.Info("========================= STARTING OPENSIM =========================");
58 m_log.Info("====================================================================");
59 m_log.InfoFormat("[OPENSIM MAIN]: Running in background {0} mode", m_sandbox ? "sandbox" : "grid");
60
61 InternalStartUp();
62
63 // We are done with startup
64 m_log.InfoFormat("[OPENSIM MAIN]: Startup complete, serving {0} region{1}",
65 m_clientServers.Count.ToString(), m_clientServers.Count > 1 ? "s" : "");
66
67 WorldHasComeToAnEnd.WaitOne();
68 }
69
70 /// <summary>
71 /// Performs any last-minute sanity checking and shuts down the region server
72 /// </summary>
73 public override void Shutdown()
74 {
75 WorldHasComeToAnEnd.Set();
76
77 base.Shutdown();
78 }
79 }
80}
diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimBase.cs
index 03dbf78..468881e 100644
--- a/OpenSim/Region/Application/OpenSimMain.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -50,7 +50,10 @@ using OpenSim.Region.Physics.Manager;
50 50
51namespace OpenSim 51namespace OpenSim
52{ 52{
53 public class OpenSimMain : RegionApplicationBase 53 /// <summary>
54 /// Common OpenSim region service code
55 /// </summary>
56 public class OpenSimBase : RegionApplicationBase
54 { 57 {
55 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 58 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
56 59
@@ -139,7 +142,7 @@ namespace OpenSim
139 set { m_moduleLoader = value; } 142 set { m_moduleLoader = value; }
140 } 143 }
141 144
142 public OpenSimMain(IConfigSource configSource) 145 public OpenSimBase(IConfigSource configSource)
143 : base() 146 : base()
144 { 147 {
145 IConfig startupConfig = configSource.Configs["Startup"]; 148 IConfig startupConfig = configSource.Configs["Startup"];
@@ -321,36 +324,7 @@ namespace OpenSim
321 m_dumpAssetsToFile = standaloneConfig.GetBoolean("dump_assets_to_file", false); 324 m_dumpAssetsToFile = standaloneConfig.GetBoolean("dump_assets_to_file", false);
322 } 325 }
323 326
324
325 m_networkServersInfo.loadFromConfiguration(m_config); 327 m_networkServersInfo.loadFromConfiguration(m_config);
326
327 }
328
329 private ManualResetEvent WorldHasComeToAnEnd = new ManualResetEvent(false);
330
331 /// <summary>
332 /// Performs initialisation of the scene, such as loading configuration from disk.
333 /// </summary>
334 public override void StartUp()
335 {
336 //
337 // Called from app startup (OpenSim.Application)
338 //
339 m_log.Info("====================================================================");
340 m_log.Info("========================= STARTING OPENSIM =========================");
341 m_log.Info("====================================================================");
342 m_log.InfoFormat("[OPENSIM MAIN]: Running in background {0} mode", m_sandbox ? "sandbox" : "grid");
343
344 InternalStartUp();
345
346 // We are done with startup
347 m_log.InfoFormat("[OPENSIM MAIN]: Startup complete, serving {0} region{1}",
348 m_clientServers.Count.ToString(), m_clientServers.Count > 1 ? "s" : "");
349
350 WorldHasComeToAnEnd.WaitOne();
351 m_log.Info("[OPENSIM MAIN]: Shutdown complete, goodbye.");
352
353 Environment.Exit(0);
354 } 328 }
355 329
356 /// <summary> 330 /// <summary>
@@ -692,8 +666,6 @@ namespace OpenSim
692 666
693 m_sceneManager.Close(); 667 m_sceneManager.Close();
694 668
695 WorldHasComeToAnEnd.Set();
696
697 base.Shutdown(); 669 base.Shutdown();
698 } 670 }
699 671
@@ -727,3 +699,4 @@ namespace OpenSim
727 } 699 }
728 } 700 }
729} 701}
702
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
102 { 102 {
103 // no default config files, so set default values, and save it 103 // no default config files, so set default values, and save it
104 Console.WriteLine("We didn't find a config!"); 104 Console.WriteLine("We didn't find a config!");
105 config.Merge(OpenSimMain.DefaultConfig()); 105 config.Merge(OpenSimBase.DefaultConfig());
106 config.Merge(configSource); 106 config.Merge(configSource);
107 } 107 }
108 108