aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Application
diff options
context:
space:
mode:
authorMW2007-08-04 18:15:48 +0000
committerMW2007-08-04 18:15:48 +0000
commitf1e10e555d1cc7bee40b4fd05caf2507c5808816 (patch)
tree26b17b33db5726efb0f5a4983a607401fa58d04a /OpenSim/Region/Application
parentOpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs (diff)
downloadopensim-SC_OLD-f1e10e555d1cc7bee40b4fd05caf2507c5808816.zip
opensim-SC_OLD-f1e10e555d1cc7bee40b4fd05caf2507c5808816.tar.gz
opensim-SC_OLD-f1e10e555d1cc7bee40b4fd05caf2507c5808816.tar.bz2
opensim-SC_OLD-f1e10e555d1cc7bee40b4fd05caf2507c5808816.tar.xz
clean up of startup config settings (command line args etc),
Now using the Nini configuration library (suggest we look into using this for the rest of our config handling, as it provides a standard interface for command line args, INI files, Xml files, .NET config files, and windows registry). One IMPORTANT change is that to TO START GRIDMODE , you need to now use -gridmode=true . Also need someone to test it under mono. (there is a dll that has been compiled under mono available, just hoping that we don't have to deal with separate dlls for windows and linux.
Diffstat (limited to 'OpenSim/Region/Application')
-rw-r--r--OpenSim/Region/Application/Application.cs71
-rw-r--r--OpenSim/Region/Application/OpenSimMain.cs73
2 files changed, 55 insertions, 89 deletions
diff --git a/OpenSim/Region/Application/Application.cs b/OpenSim/Region/Application/Application.cs
index a8c40ec..b07a4d6 100644
--- a/OpenSim/Region/Application/Application.cs
+++ b/OpenSim/Region/Application/Application.cs
@@ -28,6 +28,7 @@
28using System; 28using System;
29using OpenSim.Framework.Console; 29using OpenSim.Framework.Console;
30using OpenSim.Region.Environment.Scenes; 30using OpenSim.Region.Environment.Scenes;
31using Nini.Config;
31 32
32namespace OpenSim 33namespace OpenSim
33{ 34{
@@ -52,70 +53,16 @@ namespace OpenSim
52 53
53 Console.WriteLine("Starting...\n"); 54 Console.WriteLine("Starting...\n");
54 55
55 bool sandBoxMode = true; 56 ArgvConfigSource source = new ArgvConfigSource(args);
56 bool startLoginServer = true;
57 string physicsEngine = "basicphysics";
58 57
59 bool userAccounts = false; 58 source.AddSwitch("Startup", "inifile");
60 bool gridLocalAsset = false; 59 source.AddSwitch("Startup", "configfile");
61 bool useConfigFile = false; 60 source.AddSwitch("Startup", "gridmode");
62 bool silent = false; 61 source.AddSwitch("Startup", "physics");
63 string configFile = "simconfig.xml"; 62 source.AddSwitch("Startup", "config");
64 63 source.AddSwitch("Startup", "noverbose");
65 for (int i = 0; i < args.Length; i++)
66 {
67 if (args[i] == "-gridmode")
68 {
69 sandBoxMode = false;
70 startLoginServer = false;
71 }
72
73 if (args[i] == "-accounts")
74 {
75 userAccounts = true;
76 }
77 if (args[i] == "-realphysx")
78 {
79 physicsEngine = "RealPhysX";
80 }
81 if (args[i] == "-bulletX")
82 {
83 physicsEngine = "BulletXEngine";
84 }
85 if (args[i] == "-ode")
86 {
87 physicsEngine = "OpenDynamicsEngine";
88 }
89 if (args[i] == "-localasset")
90 {
91 gridLocalAsset = true;
92 }
93 if (args[i] == "-configfile")
94 {
95 useConfigFile = true;
96 }
97 if (args[i] == "-noverbose")
98 {
99 silent = true;
100 }
101 if (args[i] == "-config")
102 {
103 try
104 {
105 i++;
106 configFile = args[i];
107 }
108 catch (Exception e)
109 {
110 Console.WriteLine("-config: Please specify a config file. (" + e.ToString() + ")");
111 }
112 }
113 }
114
115 OpenSimMain sim = new OpenSimMain(sandBoxMode, startLoginServer, physicsEngine, useConfigFile, silent, configFile);
116 64
117 sim.user_accounts = userAccounts; 65 OpenSimMain sim = new OpenSimMain(source);
118 sim.m_gridLocalAsset = gridLocalAsset;
119 66
120 sim.StartUp(); 67 sim.StartUp();
121 68
diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs
index fbd6790..c68f75e 100644
--- a/OpenSim/Region/Application/OpenSimMain.cs
+++ b/OpenSim/Region/Application/OpenSimMain.cs
@@ -29,6 +29,7 @@
29using System; 29using System;
30using System.IO; 30using System.IO;
31using libsecondlife; 31using libsecondlife;
32using Nini.Config;
32using OpenSim.Assets; 33using OpenSim.Assets;
33using OpenSim.Framework; 34using OpenSim.Framework;
34using OpenSim.Framework.Communications; 35using OpenSim.Framework.Communications;
@@ -39,7 +40,7 @@ using OpenSim.Framework.Servers;
39using OpenSim.Framework.Types; 40using OpenSim.Framework.Types;
40using OpenSim.Framework.Configuration; 41using OpenSim.Framework.Configuration;
41using OpenSim.Physics.Manager; 42using OpenSim.Physics.Manager;
42 43
43using OpenSim.Region.ClientStack; 44using OpenSim.Region.ClientStack;
44using OpenSim.Region.Communications.Local; 45using OpenSim.Region.Communications.Local;
45using OpenSim.Region.Communications.OGS1; 46using OpenSim.Region.Communications.OGS1;
@@ -57,7 +58,6 @@ namespace OpenSim
57 { 58 {
58 public string m_physicsEngine; 59 public string m_physicsEngine;
59 public bool m_sandbox; 60 public bool m_sandbox;
60 public bool m_loginserver;
61 public bool user_accounts; 61 public bool user_accounts;
62 public bool m_gridLocalAsset; 62 public bool m_gridLocalAsset;
63 protected bool m_useConfigFile; 63 protected bool m_useConfigFile;
@@ -70,18 +70,37 @@ namespace OpenSim
70 private bool m_silent; 70 private bool m_silent;
71 private string m_logFilename = ("region-console-" + Guid.NewGuid().ToString() + ".log"); 71 private string m_logFilename = ("region-console-" + Guid.NewGuid().ToString() + ".log");
72 72
73 public OpenSimMain(bool sandBoxMode, bool startLoginServer, string physicsEngineName, bool useConfigFile, bool silent, string configFileName) 73 public OpenSimMain(IConfigSource configSource)
74 :base( ) 74 : base()
75 {
76 IConfigSource startupSource = configSource;
77 string iniFile = startupSource.Configs["Startup"].GetString("inifile", "NA");
78 if (iniFile != "NA")
79 {
80 //a ini is set to be used for startup settings
81 string iniFilePath = Path.Combine(Util.configDir(), iniFile);
82 if (File.Exists(iniFilePath))
83 {
84 startupSource = new IniConfigSource(iniFilePath);
85
86 //enable follow line, if we want the original config source(normally commandline args) merged with ini file settings.
87 //in this case we have it so if both sources have the same named setting, command line value will overwrite the ini file value.
88 //(as if someone has bothered to enter a command line arg, we should take notice of it)
89 //startupSource.Merge(configSource);
90 }
91 }
92 ReadConfigSettings(startupSource);
93 }
94
95 protected void ReadConfigSettings(IConfigSource configSource)
75 { 96 {
76 m_useConfigFile = useConfigFile; 97 m_useConfigFile = configSource.Configs["Startup"].GetBoolean("configfile", false);
77 m_sandbox = sandBoxMode; 98 m_sandbox = !configSource.Configs["Startup"].GetBoolean("gridmode", false);
78 m_loginserver = startLoginServer; 99 m_physicsEngine = configSource.Configs["Startup"].GetString("physics", "basicphysics");
79 m_physicsEngine = physicsEngineName; 100 m_configFileName = configSource.Configs["Startup"].GetString("config", "simconfig.xml");
80 m_configFileName = configFileName; 101 m_silent = configSource.Configs["Startup"].GetBoolean("noverbose", false);
81 m_silent = silent;
82 } 102 }
83 103
84
85 /// <summary> 104 /// <summary>
86 /// Performs initialisation of the scene, such as loading configuration from disk. 105 /// Performs initialisation of the scene, such as loading configuration from disk.
87 /// </summary> 106 /// </summary>
@@ -91,7 +110,7 @@ namespace OpenSim
91 { 110 {
92 Directory.CreateDirectory(Util.logDir()); 111 Directory.CreateDirectory(Util.logDir());
93 } 112 }
94 m_log = new LogBase(Path.Combine(Util.logDir(),m_logFilename), "Region", this, m_silent); 113 m_log = new LogBase(Path.Combine(Util.logDir(), m_logFilename), "Region", this, m_silent);
95 MainLog.Instance = m_log; 114 MainLog.Instance = m_log;
96 115
97 base.StartUp(); 116 base.StartUp();
@@ -103,11 +122,11 @@ namespace OpenSim
103 122
104 if (m_sandbox) 123 if (m_sandbox)
105 { 124 {
106 m_commsManager = new CommunicationsLocal( m_networkServersInfo, m_httpServer, m_assetCache); 125 m_commsManager = new CommunicationsLocal(m_networkServersInfo, m_httpServer, m_assetCache);
107 } 126 }
108 else 127 else
109 { 128 {
110 m_commsManager = new CommunicationsOGS1( m_networkServersInfo, m_httpServer , m_assetCache); 129 m_commsManager = new CommunicationsOGS1(m_networkServersInfo, m_httpServer, m_assetCache);
111 } 130 }
112 131
113 132
@@ -129,15 +148,15 @@ namespace OpenSim
129 148
130 for (int i = 0; i < configFiles.Length; i++) 149 for (int i = 0; i < configFiles.Length; i++)
131 { 150 {
132 Console.WriteLine("Loading region config file"); 151 //Console.WriteLine("Loading region config file");
133 RegionInfo regionInfo = new RegionInfo("REGION CONFIG #" + (i + 1), configFiles[i]); 152 RegionInfo regionInfo = new RegionInfo("REGION CONFIG #" + (i + 1), configFiles[i]);
134 153
135 UDPServer udpServer; 154 UDPServer udpServer;
136 Scene scene = SetupScene(regionInfo, out udpServer); 155 Scene scene = SetupScene(regionInfo, out udpServer);
137 156
138 m_localScenes.Add(scene); 157 m_localScenes.Add(scene);
139 158
140 159
141 m_udpServers.Add(udpServer); 160 m_udpServers.Add(udpServer);
142 m_regionData.Add(regionInfo); 161 m_regionData.Add(regionInfo);
143 } 162 }
@@ -148,7 +167,7 @@ namespace OpenSim
148 this.m_udpServers[i].ServerListener(); 167 this.m_udpServers[i].ServerListener();
149 } 168 }
150 169
151 170
152 } 171 }
153 172
154 protected override StorageManager CreateStorageManager(RegionInfo regionInfo) 173 protected override StorageManager CreateStorageManager(RegionInfo regionInfo)
@@ -160,10 +179,10 @@ namespace OpenSim
160 { 179 {
161 return new Scene(regionInfo, circuitManager, m_commsManager, m_assetCache, storageManager, m_httpServer); 180 return new Scene(regionInfo, circuitManager, m_commsManager, m_assetCache, storageManager, m_httpServer);
162 } 181 }
163 182
164 protected override void Initialize() 183 protected override void Initialize()
165 { 184 {
166 m_networkServersInfo = new NetworkServersInfo("NETWORK SERVERS INFO", Path.Combine(Util.configDir(),"network_servers_information.xml")); 185 m_networkServersInfo = new NetworkServersInfo("NETWORK SERVERS INFO", Path.Combine(Util.configDir(), "network_servers_information.xml"));
167 m_httpServerPort = m_networkServersInfo.HttpListenerPort; 186 m_httpServerPort = m_networkServersInfo.HttpListenerPort;
168 m_assetCache = new AssetCache("OpenSim.Region.GridInterfaces.Local.dll", m_networkServersInfo.AssetURL, m_networkServersInfo.AssetSendKey); 187 m_assetCache = new AssetCache("OpenSim.Region.GridInterfaces.Local.dll", m_networkServersInfo.AssetURL, m_networkServersInfo.AssetSendKey);
169 } 188 }
@@ -174,15 +193,15 @@ namespace OpenSim
174 { 193 {
175 Directory.CreateDirectory(Util.logDir()); 194 Directory.CreateDirectory(Util.logDir());
176 } 195 }
177 196
178 return new LogBase((Path.Combine(Util.logDir(),m_logFilename)), "Region", this, m_silent); 197 return new LogBase((Path.Combine(Util.logDir(), m_logFilename)), "Region", this, m_silent);
179 } 198 }
180 199
181 # region Setup methods 200 # region Setup methods
182 201
183 protected override PhysicsScene GetPhysicsScene( ) 202 protected override PhysicsScene GetPhysicsScene()
184 { 203 {
185 return GetPhysicsScene( m_physicsEngine ); 204 return GetPhysicsScene(m_physicsEngine);
186 } 205 }
187 206
188 private class SimStatusHandler : IStreamHandler 207 private class SimStatusHandler : IStreamHandler
@@ -201,7 +220,7 @@ namespace OpenSim
201 { 220 {
202 get { return "GET"; } 221 get { return "GET"; }
203 } 222 }
204 223
205 public string Path 224 public string Path
206 { 225 {
207 get { return "/simstatus/"; } 226 get { return "/simstatus/"; }