aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Application/OpenSimBase.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Application/OpenSimBase.cs')
-rw-r--r--OpenSim/Region/Application/OpenSimBase.cs120
1 files changed, 46 insertions, 74 deletions
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index 4f1b439..c3c87e7 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -100,13 +100,7 @@ namespace OpenSim
100 /// <value> 100 /// <value>
101 /// The config information passed into the OpenSimulator region server. 101 /// The config information passed into the OpenSimulator region server.
102 /// </value> 102 /// </value>
103 public OpenSimConfigSource ConfigSource 103 public OpenSimConfigSource ConfigSource { get; private set; }
104 {
105 get { return m_config; }
106 set { m_config = value; }
107 }
108
109 protected OpenSimConfigSource m_config;
110 104
111 public List<IClientNetworkServer> ClientServers 105 public List<IClientNetworkServer> ClientServers
112 { 106 {
@@ -127,14 +121,6 @@ namespace OpenSim
127 get { return m_httpServerPort; } 121 get { return m_httpServerPort; }
128 } 122 }
129 123
130 public ModuleLoader ModuleLoader
131 {
132 get { return m_moduleLoader; }
133 set { m_moduleLoader = value; }
134 }
135
136 protected ModuleLoader m_moduleLoader;
137
138 protected IRegistryCore m_applicationRegistry = new RegistryCore(); 124 protected IRegistryCore m_applicationRegistry = new RegistryCore();
139 125
140 public IRegistryCore ApplicationRegistry 126 public IRegistryCore ApplicationRegistry
@@ -154,13 +140,14 @@ namespace OpenSim
154 protected virtual void LoadConfigSettings(IConfigSource configSource) 140 protected virtual void LoadConfigSettings(IConfigSource configSource)
155 { 141 {
156 m_configLoader = new ConfigurationLoader(); 142 m_configLoader = new ConfigurationLoader();
157 m_config = m_configLoader.LoadConfigSettings(configSource, envConfigSource, out m_configSettings, out m_networkServersInfo); 143 ConfigSource = m_configLoader.LoadConfigSettings(configSource, envConfigSource, out m_configSettings, out m_networkServersInfo);
144 Config = ConfigSource.Source;
158 ReadExtraConfigSettings(); 145 ReadExtraConfigSettings();
159 } 146 }
160 147
161 protected virtual void ReadExtraConfigSettings() 148 protected virtual void ReadExtraConfigSettings()
162 { 149 {
163 IConfig networkConfig = m_config.Source.Configs["Network"]; 150 IConfig networkConfig = Config.Configs["Network"];
164 if (networkConfig != null) 151 if (networkConfig != null)
165 { 152 {
166 proxyUrl = networkConfig.GetString("proxy_url", ""); 153 proxyUrl = networkConfig.GetString("proxy_url", "");
@@ -193,7 +180,7 @@ namespace OpenSim
193 /// </summary> 180 /// </summary>
194 protected override void StartupSpecific() 181 protected override void StartupSpecific()
195 { 182 {
196 IConfig startupConfig = m_config.Source.Configs["Startup"]; 183 IConfig startupConfig = Config.Configs["Startup"];
197 if (startupConfig != null) 184 if (startupConfig != null)
198 { 185 {
199 string pidFile = startupConfig.GetString("PIDFile", String.Empty); 186 string pidFile = startupConfig.GetString("PIDFile", String.Empty);
@@ -204,27 +191,38 @@ namespace OpenSim
204 } 191 }
205 192
206 // Load the simulation data service 193 // Load the simulation data service
207 IConfig simDataConfig = m_config.Source.Configs["SimulationDataStore"]; 194 IConfig simDataConfig = Config.Configs["SimulationDataStore"];
208 if (simDataConfig == null) 195 if (simDataConfig == null)
209 throw new Exception("Configuration file is missing the [SimulationDataStore] section. Have you copied OpenSim.ini.example to OpenSim.ini to reference config-include/ files?"); 196 throw new Exception("Configuration file is missing the [SimulationDataStore] section. Have you copied OpenSim.ini.example to OpenSim.ini to reference config-include/ files?");
197
210 string module = simDataConfig.GetString("LocalServiceModule", String.Empty); 198 string module = simDataConfig.GetString("LocalServiceModule", String.Empty);
211 if (String.IsNullOrEmpty(module)) 199 if (String.IsNullOrEmpty(module))
212 throw new Exception("Configuration file is missing the LocalServiceModule parameter in the [SimulationDataStore] section."); 200 throw new Exception("Configuration file is missing the LocalServiceModule parameter in the [SimulationDataStore] section.");
213 m_simulationDataService = ServerUtils.LoadPlugin<ISimulationDataService>(module, new object[] { m_config.Source }); 201
202 m_simulationDataService = ServerUtils.LoadPlugin<ISimulationDataService>(module, new object[] { Config });
203 if (m_simulationDataService == null)
204 throw new Exception(
205 string.Format(
206 "Could not load an ISimulationDataService implementation from {0}, as configured in the LocalServiceModule parameter of the [SimulationDataStore] config section.",
207 module));
214 208
215 // Load the estate data service 209 // Load the estate data service
216 IConfig estateDataConfig = m_config.Source.Configs["EstateDataStore"]; 210 IConfig estateDataConfig = Config.Configs["EstateDataStore"];
217 if (estateDataConfig == null) 211 if (estateDataConfig == null)
218 throw new Exception("Configuration file is missing the [EstateDataStore] section. Have you copied OpenSim.ini.example to OpenSim.ini to reference config-include/ files?"); 212 throw new Exception("Configuration file is missing the [EstateDataStore] section. Have you copied OpenSim.ini.example to OpenSim.ini to reference config-include/ files?");
213
219 module = estateDataConfig.GetString("LocalServiceModule", String.Empty); 214 module = estateDataConfig.GetString("LocalServiceModule", String.Empty);
220 if (String.IsNullOrEmpty(module)) 215 if (String.IsNullOrEmpty(module))
221 throw new Exception("Configuration file is missing the LocalServiceModule parameter in the [EstateDataStore] section"); 216 throw new Exception("Configuration file is missing the LocalServiceModule parameter in the [EstateDataStore] section");
222 m_estateDataService = ServerUtils.LoadPlugin<IEstateDataService>(module, new object[] { m_config.Source });
223 217
224 base.StartupSpecific(); 218 m_estateDataService = ServerUtils.LoadPlugin<IEstateDataService>(module, new object[] { Config });
219 if (m_estateDataService == null)
220 throw new Exception(
221 string.Format(
222 "Could not load an IEstateDataService implementation from {0}, as configured in the LocalServiceModule parameter of the [EstateDataStore] config section.",
223 module));
225 224
226 // Create a ModuleLoader instance 225 base.StartupSpecific();
227 m_moduleLoader = new ModuleLoader(m_config.Source);
228 226
229 LoadPlugins(); 227 LoadPlugins();
230 foreach (IApplicationPlugin plugin in m_plugins) 228 foreach (IApplicationPlugin plugin in m_plugins)
@@ -239,7 +237,7 @@ namespace OpenSim
239 } 237 }
240 } 238 }
241 239
242 protected virtual void AddPluginCommands(CommandConsole console) 240 protected virtual void AddPluginCommands(ICommandConsole console)
243 { 241 {
244 List<string> topics = GetHelpTopics(); 242 List<string> topics = GetHelpTopics();
245 243
@@ -301,7 +299,7 @@ namespace OpenSim
301 // Called from base.StartUp() 299 // Called from base.StartUp()
302 300
303 m_httpServerPort = m_networkServersInfo.HttpListenerPort; 301 m_httpServerPort = m_networkServersInfo.HttpListenerPort;
304 SceneManager.OnRestartSim += handleRestartRegion; 302 SceneManager.OnRestartSim += HandleRestartRegion;
305 303
306 // Only enable the watchdogs when all regions are ready. Otherwise we get false positives when cpu is 304 // Only enable the watchdogs when all regions are ready. Otherwise we get false positives when cpu is
307 // heavily used during initial startup. 305 // heavily used during initial startup.
@@ -366,16 +364,10 @@ namespace OpenSim
366 } 364 }
367 365
368 IClientNetworkServer clientServer; 366 IClientNetworkServer clientServer;
369 Scene scene = SetupScene(regionInfo, proxyOffset, m_config.Source, out clientServer); 367 Scene scene = SetupScene(regionInfo, proxyOffset, Config, out clientServer);
370 368
371 m_log.Info("[MODULES]: Loading Region's modules (old style)"); 369 m_log.Info("[MODULES]: Loading Region's modules (old style)");
372 370
373 List<IRegionModule> modules = m_moduleLoader.PickupModules(scene, ".");
374
375 // This needs to be ahead of the script engine load, so the
376 // script module can pick up events exposed by a module
377 m_moduleLoader.InitialiseSharedModules(scene);
378
379 // Use this in the future, the line above will be deprecated soon 371 // Use this in the future, the line above will be deprecated soon
380 m_log.Info("[REGIONMODULES]: Loading Region's modules (new style)"); 372 m_log.Info("[REGIONMODULES]: Loading Region's modules (new style)");
381 IRegionModulesController controller; 373 IRegionModulesController controller;
@@ -426,13 +418,6 @@ namespace OpenSim
426 clientServer.Start(); 418 clientServer.Start();
427 } 419 }
428 420
429 if (do_post_init)
430 {
431 foreach (IRegionModule module in modules)
432 {
433 module.PostInitialise();
434 }
435 }
436 scene.EventManager.OnShutdown += delegate() { ShutdownRegion(scene); }; 421 scene.EventManager.OnShutdown += delegate() { ShutdownRegion(scene); };
437 422
438 mscene = scene; 423 mscene = scene;
@@ -461,10 +446,10 @@ namespace OpenSim
461 string estateOwnerPassword = null; 446 string estateOwnerPassword = null;
462 string rawEstateOwnerUuid = null; 447 string rawEstateOwnerUuid = null;
463 448
464 if (m_config.Source.Configs[ESTATE_SECTION_NAME] != null) 449 if (Config.Configs[ESTATE_SECTION_NAME] != null)
465 { 450 {
466 string defaultEstateOwnerName 451 string defaultEstateOwnerName
467 = m_config.Source.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerName", "").Trim(); 452 = Config.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerName", "").Trim();
468 string[] ownerNames = defaultEstateOwnerName.Split(' '); 453 string[] ownerNames = defaultEstateOwnerName.Split(' ');
469 454
470 if (ownerNames.Length >= 2) 455 if (ownerNames.Length >= 2)
@@ -474,9 +459,9 @@ namespace OpenSim
474 } 459 }
475 460
476 // Info to be used only on Standalone Mode 461 // Info to be used only on Standalone Mode
477 rawEstateOwnerUuid = m_config.Source.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerUUID", null); 462 rawEstateOwnerUuid = Config.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerUUID", null);
478 estateOwnerEMail = m_config.Source.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerEMail", null); 463 estateOwnerEMail = Config.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerEMail", null);
479 estateOwnerPassword = m_config.Source.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerPassword", null); 464 estateOwnerPassword = Config.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerPassword", null);
480 } 465 }
481 466
482 MainConsole.Instance.OutputFormat("Estate {0} has no owner set.", regionInfo.EstateSettings.EstateName); 467 MainConsole.Instance.OutputFormat("Estate {0} has no owner set.", regionInfo.EstateSettings.EstateName);
@@ -543,7 +528,7 @@ namespace OpenSim
543 if (account == null) 528 if (account == null)
544 { 529 {
545 m_log.ErrorFormat( 530 m_log.ErrorFormat(
546 "[OPENSIM]: Unable to store account. If this simulator is connected to a grid, you must create the estate owner account first."); 531 "[OPENSIM]: Unable to store account. If this simulator is connected to a grid, you must create the estate owner account first at the grid level.");
547 } 532 }
548 else 533 else
549 { 534 {
@@ -722,8 +707,8 @@ namespace OpenSim
722 707
723 return new Scene( 708 return new Scene(
724 regionInfo, circuitManager, sceneGridService, 709 regionInfo, circuitManager, sceneGridService,
725 simDataService, estateDataService, m_moduleLoader, false, 710 simDataService, estateDataService, false,
726 m_config.Source, m_version); 711 Config, m_version);
727 } 712 }
728 713
729 protected void ShutdownClientServer(RegionInfo whichRegion) 714 protected void ShutdownClientServer(RegionInfo whichRegion)
@@ -750,9 +735,11 @@ namespace OpenSim
750 } 735 }
751 } 736 }
752 737
753 public void handleRestartRegion(RegionInfo whichRegion) 738 protected virtual void HandleRestartRegion(RegionInfo whichRegion)
754 { 739 {
755 m_log.Info("[OPENSIM]: Got restart signal from SceneManager"); 740 m_log.InfoFormat(
741 "[OPENSIM]: Got restart signal from SceneManager for region {0} ({1},{2})",
742 whichRegion.RegionName, whichRegion.RegionLocX, whichRegion.RegionLocY);
756 743
757 ShutdownClientServer(whichRegion); 744 ShutdownClientServer(whichRegion);
758 IScene scene; 745 IScene scene;
@@ -764,7 +751,7 @@ namespace OpenSim
764 protected override PhysicsScene GetPhysicsScene(string osSceneIdentifier) 751 protected override PhysicsScene GetPhysicsScene(string osSceneIdentifier)
765 { 752 {
766 return GetPhysicsScene( 753 return GetPhysicsScene(
767 m_configSettings.PhysicsEngine, m_configSettings.MeshEngineName, m_config.Source, osSceneIdentifier); 754 m_configSettings.PhysicsEngine, m_configSettings.MeshEngineName, Config, osSceneIdentifier);
768 } 755 }
769 756
770 /// <summary> 757 /// <summary>
@@ -898,7 +885,6 @@ namespace OpenSim
898 m_log.Info("[SHUTDOWN]: Closing all threads"); 885 m_log.Info("[SHUTDOWN]: Closing all threads");
899 m_log.Info("[SHUTDOWN]: Killing listener thread"); 886 m_log.Info("[SHUTDOWN]: Killing listener thread");
900 m_log.Info("[SHUTDOWN]: Killing clients"); 887 m_log.Info("[SHUTDOWN]: Killing clients");
901 // TODO: implement this
902 m_log.Info("[SHUTDOWN]: Closing console and terminating"); 888 m_log.Info("[SHUTDOWN]: Closing console and terminating");
903 889
904 try 890 try
@@ -907,7 +893,7 @@ namespace OpenSim
907 } 893 }
908 catch (Exception e) 894 catch (Exception e)
909 { 895 {
910 m_log.ErrorFormat("[SHUTDOWN]: Ignoring failure during shutdown - {0}", e); 896 m_log.Error("[SHUTDOWN]: Ignoring failure during shutdown - ", e);
911 } 897 }
912 } 898 }
913 899
@@ -1001,9 +987,9 @@ namespace OpenSim
1001 987
1002 string defaultEstateName = null; 988 string defaultEstateName = null;
1003 989
1004 if (m_config.Source.Configs[ESTATE_SECTION_NAME] != null) 990 if (Config.Configs[ESTATE_SECTION_NAME] != null)
1005 { 991 {
1006 defaultEstateName = m_config.Source.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateName", null); 992 defaultEstateName = Config.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateName", null);
1007 993
1008 if (defaultEstateName != null) 994 if (defaultEstateName != null)
1009 { 995 {
@@ -1086,28 +1072,14 @@ namespace OpenSim
1086 MainConsole.Instance.Output("Joining the estate failed. Please try again."); 1072 MainConsole.Instance.Output("Joining the estate failed. Please try again.");
1087 } 1073 }
1088 } 1074 }
1089 } 1075 }
1090 1076
1091 return true; // need to update the database 1077 return true; // need to update the database
1092 } 1078 }
1093 } 1079 }
1094 1080
1095 public class OpenSimConfigSource 1081 public class OpenSimConfigSource
1096 { 1082 {
1097 public IConfigSource Source; 1083 public IConfigSource Source;
1098
1099 public void Save(string path)
1100 {
1101 if (Source is IniConfigSource)
1102 {
1103 IniConfigSource iniCon = (IniConfigSource) Source;
1104 iniCon.Save(path);
1105 }
1106 else if (Source is XmlConfigSource)
1107 {
1108 XmlConfigSource xmlCon = (XmlConfigSource) Source;
1109 xmlCon.Save(path);
1110 }
1111 }
1112 } 1084 }
1113} 1085} \ No newline at end of file