aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Application
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Application')
-rw-r--r--OpenSim/Region/Application/ConfigurationLoader.cs1
-rw-r--r--OpenSim/Region/Application/OpenSim.cs326
-rw-r--r--OpenSim/Region/Application/OpenSimBase.cs233
3 files changed, 163 insertions, 397 deletions
diff --git a/OpenSim/Region/Application/ConfigurationLoader.cs b/OpenSim/Region/Application/ConfigurationLoader.cs
index 8d95c41..fc3999f 100644
--- a/OpenSim/Region/Application/ConfigurationLoader.cs
+++ b/OpenSim/Region/Application/ConfigurationLoader.cs
@@ -188,7 +188,6 @@ namespace OpenSim
188 // Make sure command line options take precedence 188 // Make sure command line options take precedence
189 m_config.Source.Merge(argvSource); 189 m_config.Source.Merge(argvSource);
190 190
191
192 IConfig enVars = m_config.Source.Configs["Environment"]; 191 IConfig enVars = m_config.Source.Configs["Environment"];
193 192
194 if( enVars != null ) 193 if( enVars != null )
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index 6255515..08e4023 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -35,6 +35,7 @@ using System.Text;
35using System.Text.RegularExpressions; 35using System.Text.RegularExpressions;
36using System.Timers; 36using System.Timers;
37using log4net; 37using log4net;
38using NDesk.Options;
38using Nini.Config; 39using Nini.Config;
39using OpenMetaverse; 40using OpenMetaverse;
40using OpenSim.Framework; 41using OpenSim.Framework;
@@ -81,8 +82,8 @@ namespace OpenSim
81 { 82 {
82 base.ReadExtraConfigSettings(); 83 base.ReadExtraConfigSettings();
83 84
84 IConfig startupConfig = m_config.Source.Configs["Startup"]; 85 IConfig startupConfig = Config.Configs["Startup"];
85 IConfig networkConfig = m_config.Source.Configs["Network"]; 86 IConfig networkConfig = Config.Configs["Network"];
86 87
87 int stpMaxThreads = 15; 88 int stpMaxThreads = 15;
88 89
@@ -105,22 +106,6 @@ namespace OpenSim
105 m_timeInterval = startupConfig.GetInt("timer_Interval", 1200); 106 m_timeInterval = startupConfig.GetInt("timer_Interval", 1200);
106 } 107 }
107 108
108 if (m_logFileAppender != null)
109 {
110 if (m_logFileAppender is log4net.Appender.FileAppender)
111 {
112 log4net.Appender.FileAppender appender =
113 (log4net.Appender.FileAppender)m_logFileAppender;
114 string fileName = startupConfig.GetString("LogFile", String.Empty);
115 if (fileName != String.Empty)
116 {
117 appender.File = fileName;
118 appender.ActivateOptions();
119 }
120 m_log.InfoFormat("[LOGGING]: Logging started to file {0}", appender.File);
121 }
122 }
123
124 string asyncCallMethodStr = startupConfig.GetString("async_call_method", String.Empty); 109 string asyncCallMethodStr = startupConfig.GetString("async_call_method", String.Empty);
125 FireAndForgetMethod asyncCallMethod; 110 FireAndForgetMethod asyncCallMethod;
126 if (!String.IsNullOrEmpty(asyncCallMethodStr) && Utils.EnumTryParse<FireAndForgetMethod>(asyncCallMethodStr, out asyncCallMethod)) 111 if (!String.IsNullOrEmpty(asyncCallMethodStr) && Utils.EnumTryParse<FireAndForgetMethod>(asyncCallMethodStr, out asyncCallMethod))
@@ -163,7 +148,7 @@ namespace OpenSim
163 break; 148 break;
164 case "rest": 149 case "rest":
165 m_console = new RemoteConsole("Region"); 150 m_console = new RemoteConsole("Region");
166 ((RemoteConsole)m_console).ReadConfig(m_config.Source); 151 ((RemoteConsole)m_console).ReadConfig(Config);
167 break; 152 break;
168 default: 153 default:
169 m_console = new LocalConsole("Region"); 154 m_console = new LocalConsole("Region");
@@ -173,6 +158,7 @@ namespace OpenSim
173 158
174 MainConsole.Instance = m_console; 159 MainConsole.Instance = m_console;
175 160
161 RegisterCommonAppenders(Config.Configs["Startup"]);
176 RegisterConsoleCommands(); 162 RegisterConsoleCommands();
177 163
178 base.StartupSpecific(); 164 base.StartupSpecific();
@@ -253,8 +239,14 @@ namespace OpenSim
253 m_console.Commands.AddCommand("Debug", false, "debug teleport", "debug teleport", "Toggle teleport route debugging", Debug); 239 m_console.Commands.AddCommand("Debug", false, "debug teleport", "debug teleport", "Toggle teleport route debugging", Debug);
254 240
255 m_console.Commands.AddCommand("Debug", false, "debug scene", 241 m_console.Commands.AddCommand("Debug", false, "debug scene",
256 "debug scene <scripting> <collisions> <physics>", 242 "debug scene active|collisions|physics|scripting|teleport true|false",
257 "Turn on scene debugging", Debug); 243 "Turn on scene debugging.",
244 "If active is false then main scene update and maintenance loops are suspended.\n"
245 + "If collisions is false then collisions with other objects are turned off.\n"
246 + "If physics is false then all physics objects are non-physical.\n"
247 + "If scripting is false then no scripting operations happen.\n"
248 + "If teleport is true then some extra teleport debug information is logged.",
249 Debug);
258 250
259 m_console.Commands.AddCommand("General", false, "change region", 251 m_console.Commands.AddCommand("General", false, "change region",
260 "change region <region name>", 252 "change region <region name>",
@@ -291,7 +283,7 @@ namespace OpenSim
291 283
292 m_console.Commands.AddCommand("Archiving", false, "save oar", 284 m_console.Commands.AddCommand("Archiving", false, "save oar",
293 //"save oar [-v|--version=<N>] [-p|--profile=<url>] [<OAR path>]", 285 //"save oar [-v|--version=<N>] [-p|--profile=<url>] [<OAR path>]",
294 "save oar [-h|--home=<url>] [--noassets] [--publish] [--perm=<permissions>] [<OAR path>]", 286 "save oar [-h|--home=<url>] [--noassets] [--publish] [--perm=<permissions>] [--all] [<OAR path>]",
295 "Save a region's data to an OAR archive.", 287 "Save a region's data to an OAR archive.",
296// "-v|--version=<N> generates scene objects as per older versions of the serialization (e.g. -v=0)" + Environment.NewLine 288// "-v|--version=<N> generates scene objects as per older versions of the serialization (e.g. -v=0)" + Environment.NewLine
297 "-h|--home=<url> adds the url of the profile service to the saved user information.\n" 289 "-h|--home=<url> adds the url of the profile service to the saved user information.\n"
@@ -301,6 +293,7 @@ namespace OpenSim
301 + " this is useful if you're making oars generally available that might be reloaded to the same grid from which you published\n" 293 + " this is useful if you're making oars generally available that might be reloaded to the same grid from which you published\n"
302 + "--perm=<permissions> stops objects with insufficient permissions from being saved to the OAR.\n" 294 + "--perm=<permissions> stops objects with insufficient permissions from being saved to the OAR.\n"
303 + " <permissions> can contain one or more of these characters: \"C\" = Copy, \"T\" = Transfer\n" 295 + " <permissions> can contain one or more of these characters: \"C\" = Copy, \"T\" = Transfer\n"
296 + "--all saves all the regions in the simulator, instead of just the current region.\n"
304 + "The OAR path must be a filesystem path." 297 + "The OAR path must be a filesystem path."
305 + " If this is not given then the oar is saved to region.oar in the current directory.", 298 + " If this is not given then the oar is saved to region.oar in the current directory.",
306 SaveOar); 299 SaveOar);
@@ -310,8 +303,11 @@ namespace OpenSim
310 "Change the scale of a named prim", HandleEditScale); 303 "Change the scale of a named prim", HandleEditScale);
311 304
312 m_console.Commands.AddCommand("Users", false, "kick user", 305 m_console.Commands.AddCommand("Users", false, "kick user",
313 "kick user <first> <last> [message]", 306 "kick user <first> <last> [--force] [message]",
314 "Kick a user off the simulator", KickUserCommand); 307 "Kick a user off the simulator",
308 "The --force option will kick the user without any checks to see whether it's already in the process of closing\n"
309 + "Only use this option if you are sure the avatar is inactive and a normal kick user operation does not removed them",
310 KickUserCommand);
315 311
316 m_console.Commands.AddCommand("Users", false, "show users", 312 m_console.Commands.AddCommand("Users", false, "show users",
317 "show users [full]", 313 "show users [full]",
@@ -328,10 +324,6 @@ namespace OpenSim
328 "show circuits", 324 "show circuits",
329 "Show agent circuit data", HandleShow); 325 "Show agent circuit data", HandleShow);
330 326
331 m_console.Commands.AddCommand("Comms", false, "show http-handlers",
332 "show http-handlers",
333 "Show all registered http handlers", HandleShow);
334
335 m_console.Commands.AddCommand("Comms", false, "show pending-objects", 327 m_console.Commands.AddCommand("Comms", false, "show pending-objects",
336 "show pending-objects", 328 "show pending-objects",
337 "Show # of objects on the pending queues of all scene viewers", HandleShow); 329 "Show # of objects on the pending queues of all scene viewers", HandleShow);
@@ -365,26 +357,6 @@ namespace OpenSim
365 "restart", 357 "restart",
366 "Restart all sims in this instance", RunCommand); 358 "Restart all sims in this instance", RunCommand);
367 359
368 m_console.Commands.AddCommand("General", false, "config set",
369 "config set <section> <key> <value>",
370 "Set a config option. In most cases this is not useful since changed parameters are not dynamically reloaded. Neither do changed parameters persist - you will have to change a config file manually and restart.", HandleConfig);
371
372 m_console.Commands.AddCommand("General", false, "config get",
373 "config get [<section>] [<key>]",
374 "Synonym for config show",
375 HandleConfig);
376
377 m_console.Commands.AddCommand("General", false, "config show",
378 "config show [<section>] [<key>]",
379 "Show config information",
380 "If neither section nor field are specified, then the whole current configuration is printed." + Environment.NewLine
381 + "If a section is given but not a field, then all fields in that section are printed.",
382 HandleConfig);
383
384 m_console.Commands.AddCommand("General", false, "config save",
385 "config save <path>",
386 "Save current configuration to a file at the given path", HandleConfig);
387
388 m_console.Commands.AddCommand("General", false, "command-script", 360 m_console.Commands.AddCommand("General", false, "command-script",
389 "command-script <script>", 361 "command-script <script>",
390 "Run a command script from file", RunCommand); 362 "Run a command script from file", RunCommand);
@@ -416,6 +388,7 @@ namespace OpenSim
416 { 388 {
417 RunCommandScript(m_shutdownCommandsFile); 389 RunCommandScript(m_shutdownCommandsFile);
418 } 390 }
391
419 base.ShutdownSpecific(); 392 base.ShutdownSpecific();
420 } 393 }
421 394
@@ -453,11 +426,17 @@ namespace OpenSim
453 /// <param name="cmdparams">name of avatar to kick</param> 426 /// <param name="cmdparams">name of avatar to kick</param>
454 private void KickUserCommand(string module, string[] cmdparams) 427 private void KickUserCommand(string module, string[] cmdparams)
455 { 428 {
456 if (cmdparams.Length < 4) 429 bool force = false;
430
431 OptionSet options = new OptionSet().Add("f|force", delegate (string v) { force = v != null; });
432
433 List<string> mainParams = options.Parse(cmdparams);
434
435 if (mainParams.Count < 4)
457 return; 436 return;
458 437
459 string alert = null; 438 string alert = null;
460 if (cmdparams.Length > 4) 439 if (mainParams.Count > 4)
461 alert = String.Format("\n{0}\n", String.Join(" ", cmdparams, 4, cmdparams.Length - 4)); 440 alert = String.Format("\n{0}\n", String.Join(" ", cmdparams, 4, cmdparams.Length - 4));
462 441
463 IList agents = SceneManager.GetCurrentSceneAvatars(); 442 IList agents = SceneManager.GetCurrentSceneAvatars();
@@ -466,8 +445,8 @@ namespace OpenSim
466 { 445 {
467 RegionInfo regionInfo = presence.Scene.RegionInfo; 446 RegionInfo regionInfo = presence.Scene.RegionInfo;
468 447
469 if (presence.Firstname.ToLower().Contains(cmdparams[2].ToLower()) && 448 if (presence.Firstname.ToLower().Contains(mainParams[2].ToLower()) &&
470 presence.Lastname.ToLower().Contains(cmdparams[3].ToLower())) 449 presence.Lastname.ToLower().Contains(mainParams[3].ToLower()))
471 { 450 {
472 MainConsole.Instance.Output( 451 MainConsole.Instance.Output(
473 String.Format( 452 String.Format(
@@ -480,7 +459,7 @@ namespace OpenSim
480 else 459 else
481 presence.ControllingClient.Kick("\nYou have been logged out by an administrator.\n"); 460 presence.ControllingClient.Kick("\nYou have been logged out by an administrator.\n");
482 461
483 presence.Scene.IncomingCloseAgent(presence.UUID); 462 presence.Scene.IncomingCloseAgent(presence.UUID, force);
484 } 463 }
485 } 464 }
486 465
@@ -488,35 +467,6 @@ namespace OpenSim
488 } 467 }
489 468
490 /// <summary> 469 /// <summary>
491 /// Run an optional startup list of commands
492 /// </summary>
493 /// <param name="fileName"></param>
494 private void RunCommandScript(string fileName)
495 {
496 if (File.Exists(fileName))
497 {
498 m_log.Info("[COMMANDFILE]: Running " + fileName);
499
500 using (StreamReader readFile = File.OpenText(fileName))
501 {
502 string currentCommand;
503 while ((currentCommand = readFile.ReadLine()) != null)
504 {
505 currentCommand = currentCommand.Trim();
506 if (!(currentCommand == ""
507 || currentCommand.StartsWith(";")
508 || currentCommand.StartsWith("//")
509 || currentCommand.StartsWith("#")))
510 {
511 m_log.Info("[COMMANDFILE]: Running '" + currentCommand + "'");
512 m_console.RunCommand(currentCommand);
513 }
514 }
515 }
516 }
517 }
518
519 /// <summary>
520 /// Opens a file and uses it as input to the console command parser. 470 /// Opens a file and uses it as input to the console command parser.
521 /// </summary> 471 /// </summary>
522 /// <param name="fileName">name of file to use as input to the console</param> 472 /// <param name="fileName">name of file to use as input to the console</param>
@@ -620,111 +570,9 @@ namespace OpenSim
620 bool changed = PopulateRegionEstateInfo(regInfo); 570 bool changed = PopulateRegionEstateInfo(regInfo);
621 IScene scene; 571 IScene scene;
622 CreateRegion(regInfo, true, out scene); 572 CreateRegion(regInfo, true, out scene);
623 if (changed)
624 regInfo.EstateSettings.Save();
625 }
626
627 /// <summary>
628 /// Change and load configuration file data.
629 /// </summary>
630 /// <param name="module"></param>
631 /// <param name="cmd"></param>
632 private void HandleConfig(string module, string[] cmd)
633 {
634 List<string> args = new List<string>(cmd);
635 args.RemoveAt(0);
636 string[] cmdparams = args.ToArray();
637
638 if (cmdparams.Length > 0)
639 {
640 string firstParam = cmdparams[0].ToLower();
641
642 switch (firstParam)
643 {
644 case "set":
645 if (cmdparams.Length < 4)
646 {
647 Notice("Syntax: config set <section> <key> <value>");
648 Notice("Example: config set ScriptEngine.DotNetEngine NumberOfScriptThreads 5");
649 }
650 else
651 {
652 IConfig c;
653 IConfigSource source = new IniConfigSource();
654 c = source.AddConfig(cmdparams[1]);
655 if (c != null)
656 {
657 string _value = String.Join(" ", cmdparams, 3, cmdparams.Length - 3);
658 c.Set(cmdparams[2], _value);
659 m_config.Source.Merge(source);
660 573
661 Notice("In section [{0}], set {1} = {2}", c.Name, cmdparams[2], _value); 574 if (changed)
662 } 575 regInfo.EstateSettings.Save();
663 }
664 break;
665
666 case "get":
667 case "show":
668 if (cmdparams.Length == 1)
669 {
670 foreach (IConfig config in m_config.Source.Configs)
671 {
672 Notice("[{0}]", config.Name);
673 string[] keys = config.GetKeys();
674 foreach (string key in keys)
675 Notice(" {0} = {1}", key, config.GetString(key));
676 }
677 }
678 else if (cmdparams.Length == 2 || cmdparams.Length == 3)
679 {
680 IConfig config = m_config.Source.Configs[cmdparams[1]];
681 if (config == null)
682 {
683 Notice("Section \"{0}\" does not exist.",cmdparams[1]);
684 break;
685 }
686 else
687 {
688 if (cmdparams.Length == 2)
689 {
690 Notice("[{0}]", config.Name);
691 foreach (string key in config.GetKeys())
692 Notice(" {0} = {1}", key, config.GetString(key));
693 }
694 else
695 {
696 Notice(
697 "config get {0} {1} : {2}",
698 cmdparams[1], cmdparams[2], config.GetString(cmdparams[2]));
699 }
700 }
701 }
702 else
703 {
704 Notice("Syntax: config {0} [<section>] [<key>]", firstParam);
705 Notice("Example: config {0} ScriptEngine.DotNetEngine NumberOfScriptThreads", firstParam);
706 }
707
708 break;
709
710 case "save":
711 if (cmdparams.Length < 2)
712 {
713 Notice("Syntax: config save <path>");
714 return;
715 }
716
717 if (Application.iniFilePath == cmdparams[1])
718 {
719 Notice("Path can not be " + Application.iniFilePath);
720 return;
721 }
722
723 Notice("Saving configuration file: " + cmdparams[1]);
724 m_config.Save(cmdparams[1]);
725 break;
726 }
727 }
728 } 576 }
729 577
730 /// <summary> 578 /// <summary>
@@ -743,33 +591,13 @@ namespace OpenSim
743 switch (cmdparams[0].ToLower()) 591 switch (cmdparams[0].ToLower())
744 { 592 {
745 case "list": 593 case "list":
746 foreach (IRegionModule irm in m_moduleLoader.GetLoadedSharedModules) 594 //TODO: Convert to new region modules
747 {
748 MainConsole.Instance.Output(String.Format("Shared region module: {0}", irm.Name));
749 }
750 break; 595 break;
751 case "unload": 596 case "unload":
752 if (cmdparams.Length > 1) 597 //TODO: Convert to new region modules
753 {
754 foreach (IRegionModule rm in new ArrayList(m_moduleLoader.GetLoadedSharedModules))
755 {
756 if (rm.Name.ToLower() == cmdparams[1].ToLower())
757 {
758 MainConsole.Instance.Output(String.Format("Unloading module: {0}", rm.Name));
759 m_moduleLoader.UnloadModule(rm);
760 }
761 }
762 }
763 break; 598 break;
764 case "load": 599 case "load":
765 if (cmdparams.Length > 1) 600 //TODO: Convert to new region modules
766 {
767 foreach (Scene s in new ArrayList(SceneManager.Scenes))
768 {
769 MainConsole.Instance.Output(String.Format("Loading module: {0}", cmdparams[1]));
770 m_moduleLoader.LoadRegionModules(cmdparams[1], s);
771 }
772 }
773 break; 601 break;
774 } 602 }
775 } 603 }
@@ -793,13 +621,6 @@ namespace OpenSim
793 621
794 switch (command) 622 switch (command)
795 { 623 {
796 case "command-script":
797 if (cmdparams.Length > 0)
798 {
799 RunCommandScript(cmdparams[0]);
800 }
801 break;
802
803 case "backup": 624 case "backup":
804 MainConsole.Instance.Output("Triggering save of pending object updates to persistent store"); 625 MainConsole.Instance.Output("Triggering save of pending object updates to persistent store");
805 SceneManager.BackupCurrentScene(); 626 SceneManager.BackupCurrentScene();
@@ -843,12 +664,20 @@ namespace OpenSim
843 664
844 if (!SceneManager.TrySetCurrentScene(newRegionName)) 665 if (!SceneManager.TrySetCurrentScene(newRegionName))
845 MainConsole.Instance.Output(String.Format("Couldn't select region {0}", newRegionName)); 666 MainConsole.Instance.Output(String.Format("Couldn't select region {0}", newRegionName));
667 else
668 RefreshPrompt();
846 } 669 }
847 else 670 else
848 { 671 {
849 MainConsole.Instance.Output("Usage: change region <region name>"); 672 MainConsole.Instance.Output("Usage: change region <region name>");
850 } 673 }
674 }
851 675
676 /// <summary>
677 /// Refreshs prompt with the current selection details.
678 /// </summary>
679 private void RefreshPrompt()
680 {
852 string regionName = (SceneManager.CurrentScene == null ? "root" : SceneManager.CurrentScene.RegionInfo.RegionName); 681 string regionName = (SceneManager.CurrentScene == null ? "root" : SceneManager.CurrentScene.RegionInfo.RegionName);
853 MainConsole.Instance.Output(String.Format("Currently selected region is {0}", regionName)); 682 MainConsole.Instance.Output(String.Format("Currently selected region is {0}", regionName));
854 683
@@ -870,6 +699,18 @@ namespace OpenSim
870 m_console.ConsoleScene = SceneManager.CurrentScene; 699 m_console.ConsoleScene = SceneManager.CurrentScene;
871 } 700 }
872 701
702 protected override void HandleRestartRegion(RegionInfo whichRegion)
703 {
704 base.HandleRestartRegion(whichRegion);
705
706 // Where we are restarting multiple scenes at once, a previous call to RefreshPrompt may have set the
707 // m_console.ConsoleScene to null (indicating all scenes).
708 if (m_console.ConsoleScene != null && whichRegion.RegionName == ((Scene)m_console.ConsoleScene).Name)
709 SceneManager.TrySetCurrentScene(whichRegion.RegionName);
710
711 RefreshPrompt();
712 }
713
873 /// <summary> 714 /// <summary>
874 /// Turn on some debugging values for OpenSim. 715 /// Turn on some debugging values for OpenSim.
875 /// </summary> 716 /// </summary>
@@ -922,7 +763,8 @@ namespace OpenSim
922 } 763 }
923 else 764 else
924 { 765 {
925 MainConsole.Instance.Output("Usage: debug scene scripting|collisions|physics|teleport true|false"); 766 MainConsole.Instance.Output(
767 "Usage: debug scene active|scripting|collisions|physics|teleport true|false");
926 } 768 }
927 769
928 break; 770 break;
@@ -1002,56 +844,10 @@ namespace OpenSim
1002 HandleShowCircuits(); 844 HandleShowCircuits();
1003 break; 845 break;
1004 846
1005 case "http-handlers":
1006 System.Text.StringBuilder handlers = new System.Text.StringBuilder("Registered HTTP Handlers:\n");
1007
1008 handlers.AppendFormat("* XMLRPC:\n");
1009 foreach (String s in HttpServer.GetXmlRpcHandlerKeys())
1010 handlers.AppendFormat("\t{0}\n", s);
1011
1012 handlers.AppendFormat("* HTTP:\n");
1013 List<String> poll = HttpServer.GetPollServiceHandlerKeys();
1014 foreach (String s in HttpServer.GetHTTPHandlerKeys())
1015 handlers.AppendFormat("\t{0} {1}\n", s, (poll.Contains(s) ? "(poll service)" : string.Empty));
1016
1017 handlers.AppendFormat("* Agent:\n");
1018 foreach (String s in HttpServer.GetAgentHandlerKeys())
1019 handlers.AppendFormat("\t{0}\n", s);
1020
1021 handlers.AppendFormat("* LLSD:\n");
1022 foreach (String s in HttpServer.GetLLSDHandlerKeys())
1023 handlers.AppendFormat("\t{0}\n", s);
1024
1025 handlers.AppendFormat("* StreamHandlers ({0}):\n", HttpServer.GetStreamHandlerKeys().Count);
1026 foreach (String s in HttpServer.GetStreamHandlerKeys())
1027 handlers.AppendFormat("\t{0}\n", s);
1028
1029 MainConsole.Instance.Output(handlers.ToString());
1030 break;
1031
1032 case "modules": 847 case "modules":
1033 MainConsole.Instance.Output("The currently loaded shared modules are:");
1034 foreach (IRegionModule module in m_moduleLoader.GetLoadedSharedModules)
1035 {
1036 MainConsole.Instance.Output("Shared Module: " + module.Name);
1037 }
1038
1039 SceneManager.ForEachScene(
1040 delegate(Scene scene) {
1041 m_log.Error("The currently loaded modules in " + scene.RegionInfo.RegionName + " are:");
1042 foreach (IRegionModule module in scene.Modules.Values)
1043 {
1044 if (!module.IsSharedModule)
1045 {
1046 m_log.Error("Region Module: " + module.Name);
1047 }
1048 }
1049 }
1050 );
1051
1052 SceneManager.ForEachScene( 848 SceneManager.ForEachScene(
1053 delegate(Scene scene) { 849 delegate(Scene scene) {
1054 MainConsole.Instance.Output("Loaded new region modules in" + scene.RegionInfo.RegionName + " are:"); 850 MainConsole.Instance.Output("Loaded region modules in" + scene.RegionInfo.RegionName + " are:");
1055 foreach (IRegionModuleBase module in scene.RegionModules.Values) 851 foreach (IRegionModuleBase module in scene.RegionModules.Values)
1056 { 852 {
1057 Type type = module.GetType().GetInterface("ISharedRegionModule"); 853 Type type = module.GetType().GetInterface("ISharedRegionModule");
@@ -1123,7 +919,7 @@ namespace OpenSim
1123 aCircuit.Name, 919 aCircuit.Name,
1124 aCircuit.child ? "child" : "root", 920 aCircuit.child ? "child" : "root",
1125 aCircuit.circuitcode.ToString(), 921 aCircuit.circuitcode.ToString(),
1126 aCircuit.IPAddress.ToString(), 922 aCircuit.IPAddress != null ? aCircuit.IPAddress.ToString() : "not set",
1127 aCircuit.Viewer); 923 aCircuit.Viewer);
1128 }); 924 });
1129 925
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}