aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Application/OpenSimMain.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Application/OpenSimMain.cs')
-rw-r--r--OpenSim/Region/Application/OpenSimMain.cs725
1 files changed, 48 insertions, 677 deletions
diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs
index 93d6f56..3bee7f3 100644
--- a/OpenSim/Region/Application/OpenSimMain.cs
+++ b/OpenSim/Region/Application/OpenSimMain.cs
@@ -54,15 +54,14 @@ using Timer=System.Timers.Timer;
54 54
55namespace OpenSim 55namespace OpenSim
56{ 56{
57 public delegate void ConsoleCommand(string[] comParams); 57 public class OpenSimMain : RegionApplicationBase
58
59 public class OpenSimMain : RegionApplicationBase, conscmd_callback
60 { 58 {
61 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 59 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
62 private string proxyUrl;
63 private int proxyOffset = 0;
64 60
65 private const string DEFAULT_PRIM_BACKUP_FILENAME = "prim-backup.xml"; 61 protected string proxyUrl;
62 protected int proxyOffset = 0;
63
64 protected const string DEFAULT_PRIM_BACKUP_FILENAME = "prim-backup.xml";
66 65
67 public string m_physicsEngine; 66 public string m_physicsEngine;
68 public string m_meshEngineName; 67 public string m_meshEngineName;
@@ -76,35 +75,29 @@ namespace OpenSim
76 75
77 protected string m_storageDll; 76 protected string m_storageDll;
78 77
79 protected string m_startupCommandsFile;
80 protected string m_shutdownCommandsFile;
81
82 protected List<UDPServer> m_udpServers = new List<UDPServer>(); 78 protected List<UDPServer> m_udpServers = new List<UDPServer>();
83 protected List<RegionInfo> m_regionData = new List<RegionInfo>(); 79 protected List<RegionInfo> m_regionData = new List<RegionInfo>();
84 80
85 private bool m_physicalPrim; 81 protected bool m_physicalPrim;
86 private bool m_permissions = false; 82 protected bool m_permissions = false;
87 83
88 private bool m_standaloneAuthenticate = false; 84 protected bool m_standaloneAuthenticate = false;
89 private string m_standaloneWelcomeMessage = null; 85 protected string m_standaloneWelcomeMessage = null;
90 private string m_standaloneInventoryPlugin; 86 protected string m_standaloneInventoryPlugin;
91 private string m_standaloneAssetPlugin; 87 protected string m_standaloneAssetPlugin;
92 private string m_standaloneUserPlugin; 88 protected string m_standaloneUserPlugin;
93 private string m_standaloneInventorySource; 89 private string m_standaloneInventorySource;
94 private string m_standaloneAssetSource; 90 private string m_standaloneAssetSource;
95 private string m_standaloneUserSource; 91 private string m_standaloneUserSource;
96 92
97 private string m_assetStorage = "local"; 93 protected string m_assetStorage = "local";
98
99 private string m_timedScript = "disabled";
100 private Timer m_scriptTimer;
101 94
102 public ConsoleCommand CreateAccount = null; 95 public ConsoleCommand CreateAccount = null;
103 private bool m_dumpAssetsToFile; 96 protected bool m_dumpAssetsToFile;
104 97
105 private List<IApplicationPlugin> m_plugins = new List<IApplicationPlugin>(); 98 protected List<IApplicationPlugin> m_plugins = new List<IApplicationPlugin>();
106 99
107 private IniConfigSource m_config; 100 protected IniConfigSource m_config;
108 101
109 public IniConfigSource ConfigSource 102 public IniConfigSource ConfigSource
110 { 103 {
@@ -127,7 +120,7 @@ namespace OpenSim
127 get { return m_regionData; } 120 get { return m_regionData; }
128 } 121 }
129 122
130 private ModuleLoader m_moduleLoader; 123 protected ModuleLoader m_moduleLoader;
131 124
132 public ModuleLoader ModuleLoader 125 public ModuleLoader ModuleLoader
133 { 126 {
@@ -260,7 +253,7 @@ namespace OpenSim
260 253
261 } 254 }
262 255
263 protected void ReadConfigSettings() 256 protected virtual void ReadConfigSettings()
264 { 257 {
265 m_networkServersInfo = new NetworkServersInfo(); 258 m_networkServersInfo = new NetworkServersInfo();
266 259
@@ -290,13 +283,8 @@ namespace OpenSim
290 m_storagePersistPrimInventories 283 m_storagePersistPrimInventories
291 = startupConfig.GetBoolean("storage_prim_inventories", true); 284 = startupConfig.GetBoolean("storage_prim_inventories", true);
292 285
293 m_startupCommandsFile = startupConfig.GetString("startup_console_commands_file", String.Empty);
294 m_shutdownCommandsFile = startupConfig.GetString("shutdown_console_commands_file", String.Empty);
295
296 m_scriptEngine = startupConfig.GetString("script_engine", "OpenSim.Region.ScriptEngine.DotNetEngine.dll"); 286 m_scriptEngine = startupConfig.GetString("script_engine", "OpenSim.Region.ScriptEngine.DotNetEngine.dll");
297 m_assetStorage = startupConfig.GetString("asset_database", "local"); 287 m_assetStorage = startupConfig.GetString("asset_database", "local");
298
299 m_timedScript = startupConfig.GetString("timer_Script", "disabled");
300 } 288 }
301 289
302 IConfig standaloneConfig = m_config.Configs["StandAlone"]; 290 IConfig standaloneConfig = m_config.Configs["StandAlone"];
@@ -325,6 +313,8 @@ namespace OpenSim
325 m_networkServersInfo.loadFromConfiguration(m_config); 313 m_networkServersInfo.loadFromConfiguration(m_config);
326 } 314 }
327 315
316 private ManualResetEvent WorldHasComeToAnEnd = new ManualResetEvent(false);
317
328 /// <summary> 318 /// <summary>
329 /// Performs initialisation of the scene, such as loading configuration from disk. 319 /// Performs initialisation of the scene, such as loading configuration from disk.
330 /// </summary> 320 /// </summary>
@@ -334,14 +324,30 @@ namespace OpenSim
334 // Called from app startup (OpenSim.Application) 324 // Called from app startup (OpenSim.Application)
335 // 325 //
336 326
337 m_log.Info("===================================================================="); 327 m_log.Info("[OPENSIM]: Starting Opensim");
338 m_log.Info("========================= STARTING OPENSIM =========================");
339 m_log.Info("====================================================================");
340 m_log.InfoFormat("[OPENSIM MAIN]: Running in {0} mode", (m_sandbox ? "sandbox" : "grid")); 328 m_log.InfoFormat("[OPENSIM MAIN]: Running in {0} mode", (m_sandbox ? "sandbox" : "grid"));
341 329
342 m_console = CreateConsole(); 330 InternalStartUp();
343 MainConsole.Instance = m_console; 331
332 // We are done with startup
333 m_log.Info("[OPENSIM MAIN]: Startup complete, serving " + m_udpServers.Count.ToString() + " region(s)");
334 WorldHasComeToAnEnd.WaitOne();
335 }
336
337
338 /// <summary>
339 /// Signal that the end of the world is now.
340 /// </summary>
341 public void ApocalypseNow()
342 {
343 WorldHasComeToAnEnd.Set();
344 }
344 345
346 /// <summary>
347 /// Performs initialisation of the scene, such as loading configuration from disk.
348 /// </summary>
349 protected void InternalStartUp()
350 {
345 StatsManager.StartCollectingSimExtraStats(); 351 StatsManager.StartCollectingSimExtraStats();
346 352
347 // Do baseclass startup sequence: OpenSim.Region.ClientStack.RegionApplicationBase.StartUp 353 // Do baseclass startup sequence: OpenSim.Region.ClientStack.RegionApplicationBase.StartUp
@@ -411,28 +417,6 @@ namespace OpenSim
411 // m_udpServers[i].ServerListener(); 417 // m_udpServers[i].ServerListener();
412 // } 418 // }
413 419
414 //Run Startup Commands
415 if (m_startupCommandsFile != String.Empty)
416 {
417 RunCommandScript(m_startupCommandsFile);
418 }
419 else
420 {
421 m_log.Info("[STARTUP]: No startup command script specified. Moving on...");
422 }
423
424 // Start timer script (run a script every xx seconds)
425 if (m_timedScript != "disabled")
426 {
427 m_scriptTimer = new Timer();
428 m_scriptTimer.Enabled = true;
429 m_scriptTimer.Interval = (int)(1200 * 1000);
430 m_scriptTimer.Elapsed += new ElapsedEventHandler(RunAutoTimerScript);
431 }
432
433 // We are done with startup
434 PrintFileToConsole("startuplogo.txt");
435 m_log.Info("[OPENSIM MAIN]: Startup complete, serving " + m_udpServers.Count.ToString() + " region(s)");
436 } 420 }
437 421
438 protected override void Initialize() 422 protected override void Initialize()
@@ -644,11 +628,6 @@ namespace OpenSim
644 //m_sceneManager.SendSimOnlineNotification(restartingRegion.RegionHandle); 628 //m_sceneManager.SendSimOnlineNotification(restartingRegion.RegionHandle);
645 } 629 }
646 630
647 protected override ConsoleBase CreateConsole()
648 {
649 return new ConsoleBase("Region", this);
650 }
651
652 # region Setup methods 631 # region Setup methods
653 632
654 protected override PhysicsScene GetPhysicsScene() 633 protected override PhysicsScene GetPhysicsScene()
@@ -656,7 +635,7 @@ namespace OpenSim
656 return GetPhysicsScene(m_physicsEngine, m_meshEngineName); 635 return GetPhysicsScene(m_physicsEngine, m_meshEngineName);
657 } 636 }
658 637
659 private class SimStatusHandler : IStreamedRequestHandler 638 protected class SimStatusHandler : IStreamedRequestHandler
660 { 639 {
661 public byte[] Handle(string path, Stream request) 640 public byte[] Handle(string path, Stream request)
662 { 641 {
@@ -684,18 +663,13 @@ namespace OpenSim
684 /// <summary> 663 /// <summary>
685 /// Performs any last-minute sanity checking and shuts down the region server 664 /// Performs any last-minute sanity checking and shuts down the region server
686 /// </summary> 665 /// </summary>
687 public virtual void Shutdown() 666 protected virtual void InternalShutdown()
688 { 667 {
689 if (proxyUrl.Length > 0) 668 if (proxyUrl.Length > 0)
690 { 669 {
691 Util.XmlRpcCommand(proxyUrl, "Stop"); 670 Util.XmlRpcCommand(proxyUrl, "Stop");
692 } 671 }
693 672
694 if (m_startupCommandsFile != String.Empty)
695 {
696 RunCommandScript(m_shutdownCommandsFile);
697 }
698
699 m_log.Info("[SHUTDOWN]: Closing all threads"); 673 m_log.Info("[SHUTDOWN]: Closing all threads");
700 m_log.Info("[SHUTDOWN]: Killing listener thread"); 674 m_log.Info("[SHUTDOWN]: Killing listener thread");
701 m_log.Info("[SHUTDOWN]: Killing clients"); 675 m_log.Info("[SHUTDOWN]: Killing clients");
@@ -703,619 +677,16 @@ namespace OpenSim
703 m_log.Info("[SHUTDOWN]: Closing console and terminating"); 677 m_log.Info("[SHUTDOWN]: Closing console and terminating");
704 678
705 m_sceneManager.Close(); 679 m_sceneManager.Close();
706 680 // needs to be called by Shutdown() method
707 m_console.Close(); 681 // Environment.Exit(0);
708 Environment.Exit(0);
709 }
710
711 private void RunAutoTimerScript(object sender, EventArgs e)
712 {
713 if (m_timedScript != "disabled")
714 {
715 RunCommandScript(m_timedScript);
716 }
717 }
718
719 #region Console Commands
720
721 /// <summary>
722 ///
723 /// </summary>
724 /// <param name="fileName"></param>
725 private void RunCommandScript(string fileName)
726 {
727 m_log.Info("[COMMANDFILE]: Running " + fileName);
728 if (File.Exists(fileName))
729 {
730 StreamReader readFile = File.OpenText(fileName);
731 string currentCommand = String.Empty;
732 while ((currentCommand = readFile.ReadLine()) != null)
733 {
734 if (currentCommand != String.Empty)
735 {
736 m_log.Info("[COMMANDFILE]: Running '" + currentCommand + "'");
737 m_console.RunCommand(currentCommand);
738 }
739 }
740 }
741 else
742 {
743 m_log.Error("[COMMANDFILE]: Command script missing. Can not run commands");
744 }
745 }
746
747 private void PrintFileToConsole(string fileName)
748 {
749 if (File.Exists(fileName))
750 {
751 StreamReader readFile = File.OpenText(fileName);
752 string currentLine = String.Empty;
753 while ((currentLine = readFile.ReadLine()) != null)
754 {
755 m_log.Info("[!]" + currentLine);
756 }
757 }
758 } 682 }
759 683
760 684 public virtual void Shutdown()
761 /// <summary>
762 /// Runs commands issued by the server console from the operator
763 /// </summary>
764 /// <param name="command">The first argument of the parameter (the command)</param>
765 /// <param name="cmdparams">Additional arguments passed to the command</param>
766 public override void RunCmd(string command, string[] cmdparams)
767 {
768 base.RunCmd(command, cmdparams);
769
770 switch (command)
771 {
772 case "clear-assets":
773 m_assetCache.Clear();
774 break;
775
776 case "set-time":
777 m_sceneManager.SetCurrentSceneTimePhase(Convert.ToInt32(cmdparams[0]));
778 break;
779
780 case "force-update":
781 m_console.Notice("Updating all clients");
782 m_sceneManager.ForceCurrentSceneClientUpdate();
783 break;
784
785 case "edit-scale":
786 if (cmdparams.Length == 4)
787 {
788 m_sceneManager.HandleEditCommandOnCurrentScene(cmdparams);
789 }
790 break;
791
792 case "debug":
793 if (cmdparams.Length > 0)
794 {
795 Debug(cmdparams);
796 }
797 break;
798
799 case "scene-debug":
800 if (cmdparams.Length == 3)
801 {
802 if (m_sceneManager.CurrentScene == null)
803 {
804 m_console.Error("CONSOLE", "Please use 'change-region <regioname>' first");
805 }
806 else
807 {
808 m_sceneManager.CurrentScene.SetSceneCoreDebug(!Convert.ToBoolean(cmdparams[0]), !Convert.ToBoolean(cmdparams[1]), !Convert.ToBoolean(cmdparams[2]));
809 }
810 }
811 else
812 {
813 m_console.Error("scene-debug <scripting> <collisions> <physics> (where inside <> is true/false)");
814 }
815 break;
816
817 case "help":
818 m_console.Notice("alert - send alert to a designated user or all users.");
819 m_console.Notice(" alert [First] [Last] [Message] - send an alert to a user. Case sensitive.");
820 m_console.Notice(" alert general [Message] - send an alert to all users.");
821 m_console.Notice("backup - trigger a simulator backup");
822 m_console.Notice("change-region [name] - sets the region that many of these commands affect.");
823 m_console.Notice("clear-assets - clear asset cache");
824 m_console.Notice("command-script [filename] - Execute command in a file.");
825 m_console.Notice("config get section field - get a config value");
826 m_console.Notice("config save - save OpenSim.ini");
827 m_console.Notice("config set section field value - set a config value");
828 m_console.Notice("create-region <name> <regionfile.xml> - creates a new region");
829 m_console.Notice("create user - adds a new user.");
830 m_console.Notice("debug - debugging commands");
831 m_console.Notice(" packet 0..255 - print incoming/outgoing packets (0=off)");
832 m_console.Notice("scene-debug [scripting] [collision] [physics] - Enable/Disable debug stuff, each can be True/False");
833 m_console.Notice("edit-scale [prim name] [x] [y] [z] - resize given prim");
834 m_console.Notice("export-map [filename] - save image of world map");
835 m_console.Notice("force-update - force an update of prims in the scene");
836 m_console.Notice("load-xml2 [filename] - load prims from XML using version 2 format");
837 m_console.Notice("permissions [true/false] - turn on/off permissions on the scene");
838 m_console.Notice("quit - equivalent to shutdown.");
839 m_console.Notice("remove-region [name] - remove a region");
840 m_console.Notice("restart - disconnects all clients and restarts the sims in the instance.");
841 m_console.Notice("save-xml2 [filename] - save prims to XML using version 2 format");
842 m_console.Notice("script - manually trigger scripts? or script commands?");
843 m_console.Notice("set-time [x] - set the current scene time phase");
844 m_console.Notice("show assets - show state of asset cache.");
845 m_console.Notice("show modules - shows info about loaded modules.");
846 m_console.Notice("show regions - shows info about active regions.");
847 m_console.Notice("show users - show info about connected users.");
848 m_console.Notice("show stats - statistical information for this server not displayed in the client");
849 m_console.Notice("shutdown - disconnect all clients and shutdown.");
850 m_console.Notice("terrain help - show help for terrain commands.");
851 m_console.Notice("threads - list threads");
852 break;
853
854 case "threads":
855// m_console.Notice("THREAD", Process.GetCurrentProcess().Threads.Count + " threads running:");
856// int _tc = 0;
857
858// foreach (ProcessThread pt in Process.GetCurrentProcess().Threads)
859// {
860// _tc++;
861// m_console.Notice("THREAD", _tc + ": ID: " + pt.Id + ", Started: " + pt.StartTime.ToString() + ", CPU time: " + pt.TotalProcessorTime + ", Pri: " + pt.BasePriority.ToString() + ", State: " + pt.ThreadState.ToString());
862// }
863
864 List<Thread> threads = ThreadTracker.GetThreads();
865 if (threads == null)
866 {
867 m_console.Notice("THREAD", "Thread tracking is only enabled in DEBUG mode.");
868 }
869 else
870 {
871 int _tc = 0;
872 m_console.Notice("THREAD", threads.Count + " threads are being tracked:");
873 foreach (Thread t in threads)
874 {
875 _tc++;
876 m_console.Notice("THREAD", _tc + ": ID: " + t.ManagedThreadId.ToString() + ", Name: " + t.Name + ", Alive: " + t.IsAlive.ToString() + ", Pri: " + t.Priority.ToString() + ", State: " + t.ThreadState.ToString());
877 }
878 }
879
880 break;
881 case "save-xml":
882 if (cmdparams.Length > 0)
883 {
884 m_sceneManager.SaveCurrentSceneToXml(cmdparams[0]);
885 }
886 else
887 {
888 m_sceneManager.SaveCurrentSceneToXml(DEFAULT_PRIM_BACKUP_FILENAME);
889 }
890 break;
891
892 case "load-xml":
893 LLVector3 loadOffset = new LLVector3(0, 0, 0);
894 if (cmdparams.Length > 0)
895 {
896 bool generateNewIDS = false;
897 if (cmdparams.Length > 1)
898 {
899 if (cmdparams[1] == "-newUID")
900 {
901 generateNewIDS = true;
902 }
903 if (cmdparams.Length > 2)
904 {
905 loadOffset.X = (float) Convert.ToDecimal(cmdparams[2]);
906 if (cmdparams.Length > 3)
907 {
908 loadOffset.Y = (float) Convert.ToDecimal(cmdparams[3]);
909 }
910 if (cmdparams.Length > 4)
911 {
912 loadOffset.Z = (float) Convert.ToDecimal(cmdparams[4]);
913 }
914 m_console.Error("loadOffsets <X,Y,Z> = <" + loadOffset.X + "," + loadOffset.Y + "," +
915 loadOffset.Z + ">");
916 }
917 }
918 m_sceneManager.LoadCurrentSceneFromXml(cmdparams[0], generateNewIDS, loadOffset);
919 }
920 else
921 {
922 m_sceneManager.LoadCurrentSceneFromXml(DEFAULT_PRIM_BACKUP_FILENAME, false, loadOffset);
923 }
924 break;
925
926 case "save-xml2":
927 if (cmdparams.Length > 0)
928 {
929 m_sceneManager.SaveCurrentSceneToXml2(cmdparams[0]);
930 }
931 else
932 {
933 m_sceneManager.SaveCurrentSceneToXml2(DEFAULT_PRIM_BACKUP_FILENAME);
934 }
935 break;
936
937 case "load-xml2":
938 if (cmdparams.Length > 0)
939 {
940 m_sceneManager.LoadCurrentSceneFromXml2(cmdparams[0]);
941 }
942 else
943 {
944 m_sceneManager.LoadCurrentSceneFromXml2(DEFAULT_PRIM_BACKUP_FILENAME);
945 }
946 break;
947
948 case "plugin":
949 m_sceneManager.SendCommandToPluginModules(cmdparams);
950 break;
951
952 case "command-script":
953 if (cmdparams.Length > 0)
954 {
955 RunCommandScript(cmdparams[0]);
956 }
957 break;
958
959 case "permissions":
960 // Treats each user as a super-admin when disabled
961 bool permissions = Convert.ToBoolean(cmdparams[0]);
962 m_sceneManager.SetBypassPermissionsOnCurrentScene(!permissions);
963 break;
964
965 case "backup":
966 m_sceneManager.BackupCurrentScene();
967 break;
968
969 case "alert":
970 m_sceneManager.HandleAlertCommandOnCurrentScene(cmdparams);
971 break;
972
973 case "create":
974 CreateAccount(cmdparams);
975 break;
976
977 case "create-region":
978 CreateRegion(new RegionInfo(cmdparams[0], "Regions/" + cmdparams[1],false), true);
979 break;
980 case "remove-region":
981
982 string regName = CombineParams(cmdparams, 0);
983
984 Console.WriteLine("Trying to kill: " + regName);
985 Scene killScene;
986
987 /* if (m_sceneManager.TryGetScene(regName, out killScene))
988 {
989 Console.WriteLine("Returned object ID: ", killScene.RegionInfo.RegionID.ToString());
990 Console.WriteLine("Returned object Name: ", killScene.RegionInfo.RegionName);
991
992
993 if (killScene == null)
994 {
995 Console.WriteLine("Returned object is null!");
996 }
997
998 if (m_sceneManager.CurrentScene.RegionInfo.RegionID == killScene.RegionInfo.RegionID)
999 {
1000 m_sceneManager.TrySetCurrentScene("..");
1001 }
1002
1003 m_regionData.Remove(killScene.RegionInfo);
1004 m_sceneManager.CloseScene(killScene);
1005
1006
1007 }*/
1008
1009
1010 /// note from John R Sohn aka XenReborn (irc.freenode.net)
1011 /// the trygetscene function does not work
1012 /// when debugging it i noticed it did indeed find the region by name
1013 /// but the OUT parameter "scene" return an empty object
1014 /// hence the reason it threw an exception
1015 /// when the server code in this block tried to kill it
1016 /// i know its not supposed to work that way... but it seems..
1017 /// that it is.. given a flaw in the langauge or concurrency error..
1018 /// i have no idea, but for some reason, performing the search here
1019 /// locally does work, as does dynamically killing the region
1020 /// however on server restart, the region returns, i dunno if this was
1021 /// intentional or not.... i suggest creating a seperate function
1022 /// which will permanently remove all data relating to the region
1023 /// as an administrative option... maybe something like "Purge Region"
1024 ///
1025 /// i made editations with debug console output in above commented code..
1026 /// and the trygetscene(string,out scene) function to show whats happening.
1027
1028 for (int x = 0; x < m_sceneManager.Scenes.Count; x++)
1029 {
1030 if (m_sceneManager.Scenes[x].RegionInfo.RegionName.CompareTo(regName) == 0)
1031 {
1032 killScene = m_sceneManager.Scenes[x];
1033 m_regionData.Remove(killScene.RegionInfo);
1034 m_sceneManager.CloseScene(killScene);
1035 }
1036 }
1037
1038 break;
1039
1040 case "exit":
1041 case "quit":
1042 case "shutdown":
1043 Shutdown();
1044 break;
1045
1046 case "restart":
1047 m_sceneManager.RestartCurrentScene();
1048 break;
1049
1050 case "change-region":
1051 if (cmdparams.Length > 0)
1052 {
1053 string regionName = CombineParams(cmdparams, 0);
1054
1055 if (!m_sceneManager.TrySetCurrentScene(regionName))
1056 {
1057 m_console.Error("Couldn't set current region to: " + regionName);
1058 }
1059 }
1060
1061 if (m_sceneManager.CurrentScene == null)
1062 {
1063 m_console.Error("CONSOLE", "Currently at Root level. To change region please use 'change-region <regioname>'");
1064 }
1065 else
1066 {
1067 m_console.Error("CONSOLE", "Current Region: " + m_sceneManager.CurrentScene.RegionInfo.RegionName +
1068 ". To change region please use 'change-region <regioname>'");
1069 }
1070
1071 break;
1072
1073 case "export-map":
1074 if (cmdparams.Length > 0)
1075 {
1076 m_sceneManager.CurrentOrFirstScene.ExportWorldMap(cmdparams[0]);
1077 }
1078 else
1079 {
1080 m_sceneManager.CurrentOrFirstScene.ExportWorldMap("exportmap.jpg");
1081 }
1082 break;
1083
1084 case "config":
1085 string n = command.ToUpper();
1086 if (cmdparams.Length > 0)
1087 {
1088 switch (cmdparams[0].ToLower())
1089 {
1090 case "set":
1091 if (cmdparams.Length < 4)
1092 {
1093 m_console.Error(n, "SYNTAX: " + n + " SET SECTION KEY VALUE");
1094 m_console.Error(n, "EXAMPLE: " + n + " SET ScriptEngine.DotNetEngine NumberOfScriptThreads 5");
1095 }
1096 else
1097 {
1098 IConfig c = DefaultConfig().Configs[cmdparams[1]];
1099 if (c == null)
1100 c = DefaultConfig().AddConfig(cmdparams[1]);
1101 string _value = String.Join(" ", cmdparams, 3, cmdparams.Length - 3);
1102 c.Set(cmdparams[2], _value);
1103 m_config.Merge(c.ConfigSource);
1104
1105 m_console.Error(n, n + " " + n + " " + cmdparams[1] + " " + cmdparams[2] + " " +
1106 _value);
1107 }
1108 break;
1109 case "get":
1110 if (cmdparams.Length < 3)
1111 {
1112 m_console.Error(n, "SYNTAX: " + n + " GET SECTION KEY");
1113 m_console.Error(n, "EXAMPLE: " + n + " GET ScriptEngine.DotNetEngine NumberOfScriptThreads");
1114 }
1115 else
1116 {
1117 IConfig c = DefaultConfig().Configs[cmdparams[1]];
1118 if (c == null)
1119 {
1120 m_console.Notice(n, "Section \"" + cmdparams[1] + "\" does not exist.");
1121 break;
1122 }
1123 else
1124 {
1125 m_console.Notice(n + " GET " + cmdparams[1] + " " + cmdparams[2] + ": " +
1126 c.GetString(cmdparams[2]));
1127 }
1128 }
1129
1130 break;
1131 case "save":
1132 m_console.Notice("Saving configuration file: " + Application.iniFilePath);
1133 m_config.Save(Application.iniFilePath);
1134 break;
1135 }
1136 }
1137 break;
1138 case "modules":
1139 if (cmdparams.Length > 0)
1140 {
1141 switch (cmdparams[0].ToLower())
1142 {
1143 case "list":
1144 foreach (IRegionModule irm in m_moduleLoader.GetLoadedSharedModules)
1145 {
1146 m_console.Notice("Shared region module: " + irm.Name);
1147 }
1148 break;
1149 case "unload":
1150 if (cmdparams.Length > 1)
1151 {
1152 foreach (IRegionModule rm in new ArrayList(m_moduleLoader.GetLoadedSharedModules))
1153 {
1154 if (rm.Name.ToLower() == cmdparams[1].ToLower())
1155 {
1156 m_console.Notice("Unloading module: " + rm.Name);
1157 m_moduleLoader.UnloadModule(rm);
1158 }
1159 }
1160 }
1161 break;
1162 case "load":
1163 if (cmdparams.Length > 1)
1164 {
1165 foreach (Scene s in new ArrayList(m_sceneManager.Scenes))
1166 {
1167
1168 m_console.Notice("Loading module: " + cmdparams[1]);
1169 m_moduleLoader.LoadRegionModules(cmdparams[1], s);
1170 }
1171 }
1172 break;
1173 }
1174 }
1175
1176 break;
1177
1178 default:
1179 string[] tmpPluginArgs = new string[cmdparams.Length + 1];
1180 cmdparams.CopyTo(tmpPluginArgs, 1);
1181 tmpPluginArgs[0] = command;
1182
1183 m_sceneManager.SendCommandToPluginModules(tmpPluginArgs);
1184 break;
1185 }
1186 }
1187
1188 public void Debug(string[] args)
1189 {
1190 switch (args[0])
1191 {
1192 case "packet":
1193 if (args.Length > 1)
1194 {
1195 int newDebug;
1196 if (int.TryParse(args[1], out newDebug))
1197 {
1198 m_sceneManager.SetDebugPacketOnCurrentScene(newDebug);
1199 }
1200 else
1201 {
1202 m_console.Error("packet debug should be 0..2");
1203 }
1204 m_console.Notice("New packet debug: " + newDebug.ToString());
1205 }
1206
1207 break;
1208 default:
1209 m_console.Error("Unknown debug");
1210 break;
1211 }
1212 }
1213
1214 // see BaseOpenSimServer
1215 public override void Show(string ShowWhat)
1216 {
1217 base.Show(ShowWhat);
1218
1219 switch (ShowWhat)
1220 {
1221 case "assets":
1222 m_assetCache.ShowState();
1223 break;
1224
1225 case "users":
1226 IList agents = m_sceneManager.GetCurrentSceneAvatars();
1227
1228 m_console.Notice(String.Format("\nAgents connected: {0}\n", agents.Count));
1229
1230 m_console.Notice(
1231 String.Format("{0,-16}{1,-16}{2,-37}{3,-16}{4,-22}{5,-16}{6,-15}", "Firstname", "Lastname",
1232 "Agent ID", "Circuit", "IP", "Region", "Status"));
1233
1234 foreach (ScenePresence presence in agents)
1235 {
1236 RegionInfo regionInfo = m_sceneManager.GetRegionInfo(presence.RegionHandle);
1237 string regionName;
1238 EndPoint ep = null;
1239
1240 if (regionInfo == null)
1241 {
1242 regionName = "Unresolvable";
1243 }
1244 else
1245 {
1246 regionName = regionInfo.RegionName;
1247 }
1248
1249 for (int i = 0; i < m_udpServers.Count; i++)
1250 {
1251 if (m_udpServers[i].RegionHandle == presence.RegionHandle)
1252 {
1253
1254 m_udpServers[i].clientCircuits_reverse.TryGetValue(presence.ControllingClient.CircuitCode, out ep);
1255 }
1256 }
1257
1258 m_console.Notice(
1259 String.Format(
1260 "{0,-16}{1,-16}{2,-37}{3,-16}{4,-22}{5,-16}{6,-15}",
1261 presence.Firstname,
1262 presence.Lastname,
1263 presence.UUID,
1264 presence.ControllingClient.CircuitCode,
1265 ep,
1266 regionName,
1267 ((((ClientView)presence.ControllingClient).PacketProcessingEnabled)
1268 ?"Active client":"Standby client")));
1269 }
1270
1271 m_console.Notice("");
1272
1273 break;
1274 case "modules":
1275 m_console.Notice("The currently loaded shared modules are:");
1276 foreach (IRegionModule module in m_moduleLoader.GetLoadedSharedModules)
1277 {
1278 m_console.Notice("Shared Module: " + module.Name);
1279 }
1280 break;
1281
1282 case "regions":
1283 m_sceneManager.ForEachScene(
1284 delegate(Scene scene)
1285 {
1286 m_console.Notice("Region Name: " + scene.RegionInfo.RegionName + " , Region XLoc: " +
1287 scene.RegionInfo.RegionLocX + " , Region YLoc: " +
1288 scene.RegionInfo.RegionLocY);
1289 });
1290 break;
1291
1292 case "stats":
1293 if (StatsManager.SimExtraStats != null)
1294 {
1295 m_console.Notice(
1296 "STATS", Environment.NewLine + StatsManager.SimExtraStats.Report());
1297 }
1298 else
1299 {
1300 m_console.Notice("Extra sim statistics collection has not been enabled");
1301 }
1302 break;
1303 }
1304 }
1305
1306 private string CombineParams(string[] commandParams, int pos)
1307 { 685 {
1308 string result = String.Empty; 686 InternalShutdown();
1309 for (int i = pos; i < commandParams.Length; i++) 687 Environment.Exit(0);
1310 {
1311 result += commandParams[i] + " ";
1312 }
1313 result = result.TrimEnd(' ');
1314 return result;
1315 } 688 }
1316 689
1317 #endregion
1318
1319 /// <summary> 690 /// <summary>
1320 /// Get the start time and up time of Region server 691 /// Get the start time and up time of Region server
1321 /// </summary> 692 /// </summary>