diff options
author | lbsa71 | 2007-07-16 21:53:39 +0000 |
---|---|---|
committer | lbsa71 | 2007-07-16 21:53:39 +0000 |
commit | f35f5ddaf753d88d2a5ed7c334a8cc1a4ad23664 (patch) | |
tree | 210f6cbfde37e62e31142782c7f33f6cea172cb2 /OpenSim/Region/Application/OpenSimMain.cs | |
parent | * Reset IP in SimpleApp back to localhost (diff) | |
download | opensim-SC-f35f5ddaf753d88d2a5ed7c334a8cc1a4ad23664.zip opensim-SC-f35f5ddaf753d88d2a5ed7c334a8cc1a4ad23664.tar.gz opensim-SC-f35f5ddaf753d88d2a5ed7c334a8cc1a4ad23664.tar.bz2 opensim-SC-f35f5ddaf753d88d2a5ed7c334a8cc1a4ad23664.tar.xz |
* And yet more restructuring of startup sequence...
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Application/OpenSimMain.cs | 162 |
1 files changed, 74 insertions, 88 deletions
diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index 18c81a0..074b34b 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimMain.cs | |||
@@ -53,28 +53,26 @@ namespace OpenSim | |||
53 | public class OpenSimMain : RegionApplicationBase, conscmd_callback | 53 | public class OpenSimMain : RegionApplicationBase, conscmd_callback |
54 | { | 54 | { |
55 | public string m_physicsEngine; | 55 | public string m_physicsEngine; |
56 | protected IGenericConfig localConfig; | 56 | public bool m_sandbox; |
57 | public bool m_sandbox = false; | ||
58 | public bool m_loginserver; | 57 | public bool m_loginserver; |
59 | public bool user_accounts = false; | 58 | public bool user_accounts; |
60 | public bool gridLocalAsset = false; | 59 | public bool m_gridLocalAsset; |
61 | protected bool configFileSetup = false; | 60 | protected bool m_useConfigFile; |
62 | public string m_config; | 61 | public string m_configFileName; |
63 | 62 | ||
64 | protected CommunicationsManager commsManager; | 63 | protected CommunicationsManager commsManager; |
65 | // private CheckSumServer checkServer; | ||
66 | 64 | ||
67 | private bool m_silent; | 65 | private bool m_silent; |
68 | private string m_logFilename = "region-console-" + Guid.NewGuid().ToString() + ".log"; | 66 | private string m_logFilename = "region-console-" + Guid.NewGuid().ToString() + ".log"; |
69 | 67 | ||
70 | public OpenSimMain(bool sandBoxMode, bool startLoginServer, string physicsEngine, bool useConfigFile, bool silent, string configFile) | 68 | public OpenSimMain(bool sandBoxMode, bool startLoginServer, string physicsEngineName, bool useConfigFile, bool silent, string configFileName) |
71 | :base( ) | 69 | :base( ) |
72 | { | 70 | { |
73 | this.configFileSetup = useConfigFile; | 71 | m_useConfigFile = useConfigFile; |
74 | m_sandbox = sandBoxMode; | 72 | m_sandbox = sandBoxMode; |
75 | m_loginserver = startLoginServer; | 73 | m_loginserver = startLoginServer; |
76 | m_physicsEngine = physicsEngine; | 74 | m_physicsEngine = physicsEngineName; |
77 | m_config = configFile; | 75 | m_configFileName = configFileName; |
78 | m_silent = silent; | 76 | m_silent = silent; |
79 | } | 77 | } |
80 | 78 | ||
@@ -86,17 +84,13 @@ namespace OpenSim | |||
86 | { | 84 | { |
87 | base.StartUp(); | 85 | base.StartUp(); |
88 | 86 | ||
89 | m_log.Verbose("Main.cs:Startup() - Loading configuration"); | 87 | if (!m_sandbox) |
90 | this.m_networkServersInfo.InitConfig(this.m_sandbox, this.localConfig); | 88 | { |
91 | this.localConfig.Close();//for now we can close it as no other classes read from it , but this should change | 89 | m_httpServer.AddStreamHandler(new SimStatusHandler()); |
92 | 90 | } | |
93 | ScenePresence.LoadTextureFile("avatar-texture.dat"); | ||
94 | |||
95 | ClientView.TerrainManager = new TerrainManager(new SecondLife()); | ||
96 | |||
97 | this.SetupHttpListener(); | ||
98 | 91 | ||
99 | m_assetCache = new AssetCache("OpenSim.Region.GridInterfaces.Local.dll", m_networkServersInfo.AssetURL, m_networkServersInfo.AssetSendKey); | 92 | AssetCache assetCache = m_assetCache; |
93 | assetCache = new AssetCache("OpenSim.Region.GridInterfaces.Local.dll", m_networkServersInfo.AssetURL, m_networkServersInfo.AssetSendKey); | ||
100 | m_inventoryCache = new InventoryCache(); | 94 | m_inventoryCache = new InventoryCache(); |
101 | 95 | ||
102 | if (m_sandbox) | 96 | if (m_sandbox) |
@@ -108,48 +102,6 @@ namespace OpenSim | |||
108 | this.commsManager = new CommunicationsOGS1( m_networkServersInfo, m_httpServer ); | 102 | this.commsManager = new CommunicationsOGS1( m_networkServersInfo, m_httpServer ); |
109 | } | 103 | } |
110 | 104 | ||
111 | this.SetupScene(); | ||
112 | |||
113 | m_log.Verbose("Main.cs:Startup() - Initialising HTTP server"); | ||
114 | |||
115 | //Start http server | ||
116 | m_log.Verbose("Main.cs:Startup() - Starting HTTP server"); | ||
117 | m_httpServer.Start(); | ||
118 | |||
119 | // Start UDP servers | ||
120 | for (int i = 0; i < m_udpServer.Count; i++) | ||
121 | { | ||
122 | this.m_udpServer[i].ServerListener(); | ||
123 | } | ||
124 | |||
125 | } | ||
126 | |||
127 | protected override void Initialize() | ||
128 | { | ||
129 | this.localConfig = new XmlConfig(m_config); | ||
130 | this.localConfig.LoadData(); | ||
131 | |||
132 | if (this.configFileSetup) | ||
133 | { | ||
134 | this.SetupFromConfigFile(this.localConfig); | ||
135 | } | ||
136 | } | ||
137 | |||
138 | protected override LogBase CreateLog() | ||
139 | { | ||
140 | return new LogBase(m_logFilename, "Region", this, m_silent); | ||
141 | } | ||
142 | |||
143 | # region Setup methods | ||
144 | |||
145 | protected void SetupScene() | ||
146 | { | ||
147 | IGenericConfig regionConfig; | ||
148 | |||
149 | UDPServer udpServer; | ||
150 | RegionInfo m_regionInfo = new RegionInfo(); | ||
151 | AuthenticateSessionsBase authenBase; | ||
152 | |||
153 | string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Regions"); | 105 | string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Regions"); |
154 | string[] configFiles = Directory.GetFiles(path, "*.xml"); | 106 | string[] configFiles = Directory.GetFiles(path, "*.xml"); |
155 | 107 | ||
@@ -169,7 +121,18 @@ namespace OpenSim | |||
169 | 121 | ||
170 | for (int i = 0; i < configFiles.Length; i++) | 122 | for (int i = 0; i < configFiles.Length; i++) |
171 | { | 123 | { |
172 | m_regionInfo = new RegionInfo(); | 124 | Console.WriteLine("Loading region config file"); |
125 | |||
126 | IGenericConfig regionConfig = new XmlConfig(configFiles[i]); | ||
127 | RegionInfo regionInfo = new RegionInfo(); | ||
128 | regionConfig.LoadData(); | ||
129 | regionInfo.InitConfig(this.m_sandbox, regionConfig); | ||
130 | regionConfig.Close(); | ||
131 | |||
132 | |||
133 | |||
134 | AuthenticateSessionsBase authenBase; | ||
135 | |||
173 | if (m_sandbox) | 136 | if (m_sandbox) |
174 | { | 137 | { |
175 | AuthenticateSessionsBase authen = new AuthenticateSessionsBase(); // new AuthenticateSessionsLocal(); | 138 | AuthenticateSessionsBase authen = new AuthenticateSessionsBase(); // new AuthenticateSessionsLocal(); |
@@ -182,28 +145,23 @@ namespace OpenSim | |||
182 | this.AuthenticateSessionsHandler.Add(authen); | 145 | this.AuthenticateSessionsHandler.Add(authen); |
183 | authenBase = authen; | 146 | authenBase = authen; |
184 | } | 147 | } |
185 | Console.WriteLine("Loading region config file"); | ||
186 | regionConfig = new XmlConfig(configFiles[i]); | ||
187 | regionConfig.LoadData(); | ||
188 | m_regionInfo.InitConfig(this.m_sandbox, regionConfig); | ||
189 | regionConfig.Close(); | ||
190 | 148 | ||
191 | udpServer = new UDPServer(m_regionInfo.InternalEndPoint.Port, m_assetCache, this.m_inventoryCache, this.m_log, authenBase); | 149 | UDPServer udpServer = new UDPServer(regionInfo.InternalEndPoint.Port, assetCache, this.m_inventoryCache, this.m_log, authenBase); |
192 | 150 | ||
193 | m_udpServer.Add(udpServer); | 151 | m_udpServers.Add(udpServer); |
194 | this.m_regionData.Add(m_regionInfo); | 152 | m_regionData.Add(regionInfo); |
195 | 153 | ||
196 | StorageManager tmpStoreManager = new StorageManager("OpenSim.DataStore.NullStorage.dll", m_regionInfo.DataStore, m_regionInfo.RegionName); | 154 | StorageManager tmpStoreManager = GetStoreManager(regionInfo); |
197 | 155 | ||
198 | Scene scene = new Scene( m_regionInfo, authenBase, commsManager, m_assetCache, tmpStoreManager, m_httpServer); | 156 | Scene scene = new Scene(regionInfo, authenBase, commsManager, assetCache, tmpStoreManager, m_httpServer); |
199 | this.m_localWorld.Add(scene); | 157 | m_localWorld.Add(scene); |
200 | 158 | ||
201 | udpServer.LocalWorld = scene; | 159 | udpServer.LocalWorld = scene; |
202 | 160 | ||
203 | scene.LoadStorageDLL("OpenSim.Region.Storage.LocalStorageDb4o.dll"); //all these dll names shouldn't be hard coded. | 161 | scene.LoadStorageDLL("OpenSim.Region.Storage.LocalStorageDb4o.dll"); //all these dll names shouldn't be hard coded. |
204 | scene.LoadWorldMap(); | 162 | scene.LoadWorldMap(); |
205 | 163 | ||
206 | PhysicsScene physicsScene = GetPhysicsScene( m_physicsEngine ); | 164 | PhysicsScene physicsScene = GetPhysicsScene(m_physicsEngine); |
207 | 165 | ||
208 | scene.PhysScene = physicsScene; | 166 | scene.PhysScene = physicsScene; |
209 | scene.PhysScene.SetTerrain(scene.Terrain.getHeights1D()); | 167 | scene.PhysScene.SetTerrain(scene.Terrain.getHeights1D()); |
@@ -226,8 +184,46 @@ namespace OpenSim | |||
226 | scene.performParcelPrimCountUpdate(); | 184 | scene.performParcelPrimCountUpdate(); |
227 | scene.StartTimer(); | 185 | scene.StartTimer(); |
228 | } | 186 | } |
187 | |||
188 | // Start UDP servers | ||
189 | for (int i = 0; i < m_udpServers.Count; i++) | ||
190 | { | ||
191 | this.m_udpServers[i].ServerListener(); | ||
192 | } | ||
193 | |||
194 | } | ||
195 | |||
196 | protected override StorageManager GetStoreManager(RegionInfo regionInfo) | ||
197 | { | ||
198 | return new StorageManager("OpenSim.DataStore.NullStorage.dll", regionInfo.DataStore, regionInfo.RegionName); | ||
199 | } | ||
200 | |||
201 | protected override void Initialize() | ||
202 | { | ||
203 | m_log.Verbose("Loading Configuration [{0}]", m_configFileName); | ||
204 | |||
205 | IGenericConfig localConfig = new XmlConfig(m_configFileName); | ||
206 | localConfig.LoadData(); | ||
207 | |||
208 | if (m_useConfigFile) | ||
209 | { | ||
210 | SetupFromConfigFile(localConfig); | ||
211 | } | ||
212 | |||
213 | m_networkServersInfo.InitConfig(m_sandbox, localConfig); | ||
214 | m_httpServerPort = m_networkServersInfo.HttpListenerPort; | ||
215 | |||
216 | localConfig.Close(); | ||
217 | |||
218 | } | ||
219 | |||
220 | protected override LogBase CreateLog() | ||
221 | { | ||
222 | return new LogBase(m_logFilename, "Region", this, m_silent); | ||
229 | } | 223 | } |
230 | 224 | ||
225 | # region Setup methods | ||
226 | |||
231 | protected override PhysicsScene GetPhysicsScene( ) | 227 | protected override PhysicsScene GetPhysicsScene( ) |
232 | { | 228 | { |
233 | return GetPhysicsScene( m_physicsEngine ); | 229 | return GetPhysicsScene( m_physicsEngine ); |
@@ -256,16 +252,6 @@ namespace OpenSim | |||
256 | } | 252 | } |
257 | } | 253 | } |
258 | 254 | ||
259 | protected void SetupHttpListener() | ||
260 | { | ||
261 | m_httpServer = new BaseHttpServer(this.m_networkServersInfo.HttpListenerPort); //regionData[0].IPListenPort); | ||
262 | |||
263 | if (!this.m_sandbox) | ||
264 | { | ||
265 | m_httpServer.AddStreamHandler( new SimStatusHandler() ); | ||
266 | } | ||
267 | } | ||
268 | |||
269 | protected void ConnectToRemoteGridServer() | 255 | protected void ConnectToRemoteGridServer() |
270 | { | 256 | { |
271 | 257 | ||
@@ -330,12 +316,12 @@ namespace OpenSim | |||
330 | attri = configData.GetAttribute("LocalAssets"); | 316 | attri = configData.GetAttribute("LocalAssets"); |
331 | if ((attri == "") || ((attri != "false") && (attri != "true"))) | 317 | if ((attri == "") || ((attri != "false") && (attri != "true"))) |
332 | { | 318 | { |
333 | this.gridLocalAsset = false; | 319 | this.m_gridLocalAsset = false; |
334 | configData.SetAttribute("LocalAssets", "false"); | 320 | configData.SetAttribute("LocalAssets", "false"); |
335 | } | 321 | } |
336 | else if (attri == "true") | 322 | else if (attri == "true") |
337 | { | 323 | { |
338 | this.gridLocalAsset = Convert.ToBoolean(attri); | 324 | this.m_gridLocalAsset = Convert.ToBoolean(attri); |
339 | } | 325 | } |
340 | 326 | ||
341 | 327 | ||