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.cs233
1 files changed, 102 insertions, 131 deletions
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index d107b7a..bed9a49 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -104,13 +104,7 @@ namespace OpenSim
104 /// <value> 104 /// <value>
105 /// The config information passed into the OpenSimulator region server. 105 /// The config information passed into the OpenSimulator region server.
106 /// </value> 106 /// </value>
107 public OpenSimConfigSource ConfigSource 107 public OpenSimConfigSource ConfigSource { get; private set; }
108 {
109 get { return m_config; }
110 set { m_config = value; }
111 }
112
113 protected OpenSimConfigSource m_config;
114 108
115 public List<IClientNetworkServer> ClientServers 109 public List<IClientNetworkServer> ClientServers
116 { 110 {
@@ -131,14 +125,6 @@ namespace OpenSim
131 get { return m_httpServerPort; } 125 get { return m_httpServerPort; }
132 } 126 }
133 127
134 public ModuleLoader ModuleLoader
135 {
136 get { return m_moduleLoader; }
137 set { m_moduleLoader = value; }
138 }
139
140 protected ModuleLoader m_moduleLoader;
141
142 protected IRegistryCore m_applicationRegistry = new RegistryCore(); 128 protected IRegistryCore m_applicationRegistry = new RegistryCore();
143 129
144 public IRegistryCore ApplicationRegistry 130 public IRegistryCore ApplicationRegistry
@@ -158,13 +144,14 @@ namespace OpenSim
158 protected virtual void LoadConfigSettings(IConfigSource configSource) 144 protected virtual void LoadConfigSettings(IConfigSource configSource)
159 { 145 {
160 m_configLoader = new ConfigurationLoader(); 146 m_configLoader = new ConfigurationLoader();
161 m_config = m_configLoader.LoadConfigSettings(configSource, envConfigSource, out m_configSettings, out m_networkServersInfo); 147 ConfigSource = m_configLoader.LoadConfigSettings(configSource, envConfigSource, out m_configSettings, out m_networkServersInfo);
148 Config = ConfigSource.Source;
162 ReadExtraConfigSettings(); 149 ReadExtraConfigSettings();
163 } 150 }
164 151
165 protected virtual void ReadExtraConfigSettings() 152 protected virtual void ReadExtraConfigSettings()
166 { 153 {
167 IConfig networkConfig = m_config.Source.Configs["Network"]; 154 IConfig networkConfig = Config.Configs["Network"];
168 if (networkConfig != null) 155 if (networkConfig != null)
169 { 156 {
170 proxyUrl = networkConfig.GetString("proxy_url", ""); 157 proxyUrl = networkConfig.GetString("proxy_url", "");
@@ -197,7 +184,7 @@ namespace OpenSim
197 /// </summary> 184 /// </summary>
198 protected override void StartupSpecific() 185 protected override void StartupSpecific()
199 { 186 {
200 IConfig startupConfig = m_config.Source.Configs["Startup"]; 187 IConfig startupConfig = Config.Configs["Startup"];
201 if (startupConfig != null) 188 if (startupConfig != null)
202 { 189 {
203 string pidFile = startupConfig.GetString("PIDFile", String.Empty); 190 string pidFile = startupConfig.GetString("PIDFile", String.Empty);
@@ -213,29 +200,38 @@ namespace OpenSim
213 } 200 }
214 201
215 // Load the simulation data service 202 // Load the simulation data service
216 IConfig simDataConfig = m_config.Source.Configs["SimulationDataStore"]; 203 IConfig simDataConfig = Config.Configs["SimulationDataStore"];
217 if (simDataConfig == null) 204 if (simDataConfig == null)
218 throw new Exception("Configuration file is missing the [SimulationDataStore] section. Have you copied OpenSim.ini.example to OpenSim.ini to reference config-include/ files?"); 205 throw new Exception("Configuration file is missing the [SimulationDataStore] section. Have you copied OpenSim.ini.example to OpenSim.ini to reference config-include/ files?");
206
219 string module = simDataConfig.GetString("LocalServiceModule", String.Empty); 207 string module = simDataConfig.GetString("LocalServiceModule", String.Empty);
220 if (String.IsNullOrEmpty(module)) 208 if (String.IsNullOrEmpty(module))
221 throw new Exception("Configuration file is missing the LocalServiceModule parameter in the [SimulationDataStore] section."); 209 throw new Exception("Configuration file is missing the LocalServiceModule parameter in the [SimulationDataStore] section.");
222 m_simulationDataService = ServerUtils.LoadPlugin<ISimulationDataService>(module, new object[] { m_config.Source }); 210
211 m_simulationDataService = ServerUtils.LoadPlugin<ISimulationDataService>(module, new object[] { Config });
212 if (m_simulationDataService == null)
213 throw new Exception(
214 string.Format(
215 "Could not load an ISimulationDataService implementation from {0}, as configured in the LocalServiceModule parameter of the [SimulationDataStore] config section.",
216 module));
223 217
224 // Load the estate data service 218 // Load the estate data service
225 IConfig estateDataConfig = m_config.Source.Configs["EstateDataStore"]; 219 IConfig estateDataConfig = Config.Configs["EstateDataStore"];
226 if (estateDataConfig == null) 220 if (estateDataConfig == null)
227 throw new Exception("Configuration file is missing the [EstateDataStore] section. Have you copied OpenSim.ini.example to OpenSim.ini to reference config-include/ files?"); 221 throw new Exception("Configuration file is missing the [EstateDataStore] section. Have you copied OpenSim.ini.example to OpenSim.ini to reference config-include/ files?");
222
228 module = estateDataConfig.GetString("LocalServiceModule", String.Empty); 223 module = estateDataConfig.GetString("LocalServiceModule", String.Empty);
229 if (String.IsNullOrEmpty(module)) 224 if (String.IsNullOrEmpty(module))
230 throw new Exception("Configuration file is missing the LocalServiceModule parameter in the [EstateDataStore] section"); 225 throw new Exception("Configuration file is missing the LocalServiceModule parameter in the [EstateDataStore] section");
231 m_estateDataService = ServerUtils.LoadPlugin<IEstateDataService>(module, new object[] { m_config.Source });
232 226
233 base.StartupSpecific(); 227 m_estateDataService = ServerUtils.LoadPlugin<IEstateDataService>(module, new object[] { Config });
228 if (m_estateDataService == null)
229 throw new Exception(
230 string.Format(
231 "Could not load an IEstateDataService implementation from {0}, as configured in the LocalServiceModule parameter of the [EstateDataStore] config section.",
232 module));
234 233
235 m_stats = StatsManager.SimExtraStats; 234 base.StartupSpecific();
236
237 // Create a ModuleLoader instance
238 m_moduleLoader = new ModuleLoader(m_config.Source);
239 235
240 LoadPlugins(); 236 LoadPlugins();
241 237
@@ -249,51 +245,51 @@ namespace OpenSim
249 plugin.PostInitialise(); 245 plugin.PostInitialise();
250 } 246 }
251 247
252 AddPluginCommands(); 248 if (m_console != null)
249 {
250 StatsManager.RegisterConsoleCommands(m_console);
251 AddPluginCommands(m_console);
252 }
253 } 253 }
254 254
255 protected virtual void AddPluginCommands() 255 protected virtual void AddPluginCommands(ICommandConsole console)
256 { 256 {
257 // If console exists add plugin commands. 257 List<string> topics = GetHelpTopics();
258 if (m_console != null)
259 {
260 List<string> topics = GetHelpTopics();
261 258
262 foreach (string topic in topics) 259 foreach (string topic in topics)
263 { 260 {
264 string capitalizedTopic = char.ToUpper(topic[0]) + topic.Substring(1); 261 string capitalizedTopic = char.ToUpper(topic[0]) + topic.Substring(1);
265 262
266 // This is a hack to allow the user to enter the help command in upper or lowercase. This will go 263 // This is a hack to allow the user to enter the help command in upper or lowercase. This will go
267 // away at some point. 264 // away at some point.
268 m_console.Commands.AddCommand(capitalizedTopic, false, "help " + topic, 265 console.Commands.AddCommand(capitalizedTopic, false, "help " + topic,
269 "help " + capitalizedTopic, 266 "help " + capitalizedTopic,
270 "Get help on plugin command '" + topic + "'", 267 "Get help on plugin command '" + topic + "'",
271 HandleCommanderHelp); 268 HandleCommanderHelp);
272 m_console.Commands.AddCommand(capitalizedTopic, false, "help " + capitalizedTopic, 269// console.Commands.AddCommand(capitalizedTopic, false, "help " + capitalizedTopic,
273 "help " + capitalizedTopic, 270// "help " + capitalizedTopic,
274 "Get help on plugin command '" + topic + "'", 271// "Get help on plugin command '" + topic + "'",
275 HandleCommanderHelp); 272// HandleCommanderHelp);
276 273
277 ICommander commander = null; 274 ICommander commander = null;
278 275
279 Scene s = SceneManager.CurrentOrFirstScene; 276 Scene s = SceneManager.CurrentOrFirstScene;
280 277
281 if (s != null && s.GetCommanders() != null) 278 if (s != null && s.GetCommanders() != null)
282 { 279 {
283 if (s.GetCommanders().ContainsKey(topic)) 280 if (s.GetCommanders().ContainsKey(topic))
284 commander = s.GetCommanders()[topic]; 281 commander = s.GetCommanders()[topic];
285 } 282 }
286 283
287 if (commander == null) 284 if (commander == null)
288 continue; 285 continue;
289 286
290 foreach (string command in commander.Commands.Keys) 287 foreach (string command in commander.Commands.Keys)
291 { 288 {
292 m_console.Commands.AddCommand(capitalizedTopic, false, 289 console.Commands.AddCommand(capitalizedTopic, false,
293 topic + " " + command, 290 topic + " " + command,
294 topic + " " + commander.Commands[command].ShortHelp(), 291 topic + " " + commander.Commands[command].ShortHelp(),
295 String.Empty, HandleCommanderCommand); 292 String.Empty, HandleCommanderCommand);
296 }
297 } 293 }
298 } 294 }
299 } 295 }
@@ -318,7 +314,7 @@ namespace OpenSim
318 // Called from base.StartUp() 314 // Called from base.StartUp()
319 315
320 m_httpServerPort = m_networkServersInfo.HttpListenerPort; 316 m_httpServerPort = m_networkServersInfo.HttpListenerPort;
321 SceneManager.OnRestartSim += handleRestartRegion; 317 SceneManager.OnRestartSim += HandleRestartRegion;
322 318
323 // Only enable the watchdogs when all regions are ready. Otherwise we get false positives when cpu is 319 // Only enable the watchdogs when all regions are ready. Otherwise we get false positives when cpu is
324 // heavily used during initial startup. 320 // heavily used during initial startup.
@@ -383,16 +379,10 @@ namespace OpenSim
383 } 379 }
384 380
385 IClientNetworkServer clientServer; 381 IClientNetworkServer clientServer;
386 Scene scene = SetupScene(regionInfo, proxyOffset, m_config.Source, out clientServer); 382 Scene scene = SetupScene(regionInfo, proxyOffset, Config, out clientServer);
387 383
388 m_log.Info("[MODULES]: Loading Region's modules (old style)"); 384 m_log.Info("[MODULES]: Loading Region's modules (old style)");
389 385
390 List<IRegionModule> modules = m_moduleLoader.PickupModules(scene, ".");
391
392 // This needs to be ahead of the script engine load, so the
393 // script module can pick up events exposed by a module
394 m_moduleLoader.InitialiseSharedModules(scene);
395
396 // Use this in the future, the line above will be deprecated soon 386 // Use this in the future, the line above will be deprecated soon
397 m_log.Info("[REGIONMODULES]: Loading Region's modules (new style)"); 387 m_log.Info("[REGIONMODULES]: Loading Region's modules (new style)");
398 IRegionModulesController controller; 388 IRegionModulesController controller;
@@ -402,28 +392,29 @@ namespace OpenSim
402 } 392 }
403 else m_log.Error("[REGIONMODULES]: The new RegionModulesController is missing..."); 393 else m_log.Error("[REGIONMODULES]: The new RegionModulesController is missing...");
404 394
405 if (m_securePermissionsLoading) 395 // XPTO: Fix this
406 { 396// if (m_securePermissionsLoading)
407 foreach (string s in m_permsModules) 397// {
408 { 398// foreach (string s in m_permsModules)
409 if (!scene.RegionModules.ContainsKey(s)) 399// {
410 { 400// if (!scene.RegionModules.ContainsKey(s))
411 bool found = false; 401// {
412 foreach (IRegionModule m in modules) 402// bool found = false;
413 { 403// foreach (IRegionModule m in modules)
414 if (m.Name == s) 404// {
415 { 405// if (m.Name == s)
416 found = true; 406// {
417 } 407// found = true;
418 } 408// }
419 if (!found) 409// }
420 { 410// if (!found)
421 m_log.Fatal("[MODULES]: Required module " + s + " not found."); 411// {
422 Environment.Exit(0); 412// m_log.Fatal("[MODULES]: Required module " + s + " not found.");
423 } 413// Environment.Exit(0);
424 } 414// }
425 } 415// }
426 } 416// }
417// }
427 418
428 scene.SetModuleInterfaces(); 419 scene.SetModuleInterfaces();
429// First Step of bootreport sequence 420// First Step of bootreport sequence
@@ -500,13 +491,6 @@ namespace OpenSim
500 { 491 {
501 scene.SnmpService.BootInfo("Initializing region modules", scene); 492 scene.SnmpService.BootInfo("Initializing region modules", scene);
502 } 493 }
503 if (do_post_init)
504 {
505 foreach (IRegionModule module in modules)
506 {
507 module.PostInitialise();
508 }
509 }
510 scene.EventManager.OnShutdown += delegate() { ShutdownRegion(scene); }; 494 scene.EventManager.OnShutdown += delegate() { ShutdownRegion(scene); };
511 495
512 mscene = scene; 496 mscene = scene;
@@ -541,10 +525,10 @@ namespace OpenSim
541 string estateOwnerPassword = null; 525 string estateOwnerPassword = null;
542 string rawEstateOwnerUuid = null; 526 string rawEstateOwnerUuid = null;
543 527
544 if (m_config.Source.Configs[ESTATE_SECTION_NAME] != null) 528 if (Config.Configs[ESTATE_SECTION_NAME] != null)
545 { 529 {
546 string defaultEstateOwnerName 530 string defaultEstateOwnerName
547 = m_config.Source.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerName", "").Trim(); 531 = Config.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerName", "").Trim();
548 string[] ownerNames = defaultEstateOwnerName.Split(' '); 532 string[] ownerNames = defaultEstateOwnerName.Split(' ');
549 533
550 if (ownerNames.Length >= 2) 534 if (ownerNames.Length >= 2)
@@ -554,9 +538,9 @@ namespace OpenSim
554 } 538 }
555 539
556 // Info to be used only on Standalone Mode 540 // Info to be used only on Standalone Mode
557 rawEstateOwnerUuid = m_config.Source.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerUUID", null); 541 rawEstateOwnerUuid = Config.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerUUID", null);
558 estateOwnerEMail = m_config.Source.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerEMail", null); 542 estateOwnerEMail = Config.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerEMail", null);
559 estateOwnerPassword = m_config.Source.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerPassword", null); 543 estateOwnerPassword = Config.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerPassword", null);
560 } 544 }
561 545
562 MainConsole.Instance.OutputFormat("Estate {0} has no owner set.", regionInfo.EstateSettings.EstateName); 546 MainConsole.Instance.OutputFormat("Estate {0} has no owner set.", regionInfo.EstateSettings.EstateName);
@@ -623,7 +607,7 @@ namespace OpenSim
623 if (account == null) 607 if (account == null)
624 { 608 {
625 m_log.ErrorFormat( 609 m_log.ErrorFormat(
626 "[OPENSIM]: Unable to store account. If this simulator is connected to a grid, you must create the estate owner account first."); 610 "[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.");
627 } 611 }
628 else 612 else
629 { 613 {
@@ -807,8 +791,8 @@ namespace OpenSim
807 791
808 return new Scene( 792 return new Scene(
809 regionInfo, circuitManager, sceneGridService, 793 regionInfo, circuitManager, sceneGridService,
810 simDataService, estateDataService, m_moduleLoader, false, 794 simDataService, estateDataService, false,
811 m_config.Source, m_version); 795 Config, m_version);
812 } 796 }
813 797
814 protected void ShutdownClientServer(RegionInfo whichRegion) 798 protected void ShutdownClientServer(RegionInfo whichRegion)
@@ -835,9 +819,11 @@ namespace OpenSim
835 } 819 }
836 } 820 }
837 821
838 public void handleRestartRegion(RegionInfo whichRegion) 822 protected virtual void HandleRestartRegion(RegionInfo whichRegion)
839 { 823 {
840 m_log.Info("[OPENSIM]: Got restart signal from SceneManager"); 824 m_log.InfoFormat(
825 "[OPENSIM]: Got restart signal from SceneManager for region {0} ({1},{2})",
826 whichRegion.RegionName, whichRegion.RegionLocX, whichRegion.RegionLocY);
841 827
842 ShutdownClientServer(whichRegion); 828 ShutdownClientServer(whichRegion);
843 IScene scene; 829 IScene scene;
@@ -849,7 +835,7 @@ namespace OpenSim
849 protected override PhysicsScene GetPhysicsScene(string osSceneIdentifier) 835 protected override PhysicsScene GetPhysicsScene(string osSceneIdentifier)
850 { 836 {
851 return GetPhysicsScene( 837 return GetPhysicsScene(
852 m_configSettings.PhysicsEngine, m_configSettings.MeshEngineName, m_config.Source, osSceneIdentifier); 838 m_configSettings.PhysicsEngine, m_configSettings.MeshEngineName, Config, osSceneIdentifier);
853 } 839 }
854 840
855 /// <summary> 841 /// <summary>
@@ -983,7 +969,6 @@ namespace OpenSim
983 m_log.Info("[SHUTDOWN]: Closing all threads"); 969 m_log.Info("[SHUTDOWN]: Closing all threads");
984 m_log.Info("[SHUTDOWN]: Killing listener thread"); 970 m_log.Info("[SHUTDOWN]: Killing listener thread");
985 m_log.Info("[SHUTDOWN]: Killing clients"); 971 m_log.Info("[SHUTDOWN]: Killing clients");
986 // TODO: implement this
987 m_log.Info("[SHUTDOWN]: Closing console and terminating"); 972 m_log.Info("[SHUTDOWN]: Closing console and terminating");
988 973
989 try 974 try
@@ -992,7 +977,7 @@ namespace OpenSim
992 } 977 }
993 catch (Exception e) 978 catch (Exception e)
994 { 979 {
995 m_log.ErrorFormat("[SHUTDOWN]: Ignoring failure during shutdown - {0}", e); 980 m_log.Error("[SHUTDOWN]: Ignoring failure during shutdown - ", e);
996 } 981 }
997 } 982 }
998 983
@@ -1086,9 +1071,9 @@ namespace OpenSim
1086 1071
1087 string defaultEstateName = null; 1072 string defaultEstateName = null;
1088 1073
1089 if (m_config.Source.Configs[ESTATE_SECTION_NAME] != null) 1074 if (Config.Configs[ESTATE_SECTION_NAME] != null)
1090 { 1075 {
1091 defaultEstateName = m_config.Source.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateName", null); 1076 defaultEstateName = Config.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateName", null);
1092 1077
1093 if (defaultEstateName != null) 1078 if (defaultEstateName != null)
1094 { 1079 {
@@ -1171,28 +1156,14 @@ namespace OpenSim
1171 MainConsole.Instance.Output("Joining the estate failed. Please try again."); 1156 MainConsole.Instance.Output("Joining the estate failed. Please try again.");
1172 } 1157 }
1173 } 1158 }
1174 } 1159 }
1175 1160
1176 return true; // need to update the database 1161 return true; // need to update the database
1177 } 1162 }
1178 } 1163 }
1179 1164
1180 public class OpenSimConfigSource 1165 public class OpenSimConfigSource
1181 { 1166 {
1182 public IConfigSource Source; 1167 public IConfigSource Source;
1183
1184 public void Save(string path)
1185 {
1186 if (Source is IniConfigSource)
1187 {
1188 IniConfigSource iniCon = (IniConfigSource) Source;
1189 iniCon.Save(path);
1190 }
1191 else if (Source is XmlConfigSource)
1192 {
1193 XmlConfigSource xmlCon = (XmlConfigSource) Source;
1194 xmlCon.Save(path);
1195 }
1196 }
1197 } 1168 }
1198} 1169}