* And yet more restructuring of startup sequence...

afrisby
lbsa71 2007-07-16 21:53:39 +00:00
parent 1462cb1b50
commit f35f5ddaf7
4 changed files with 102 additions and 107 deletions

View File

@ -103,7 +103,7 @@ namespace OpenSim
OpenSimMain sim = new OpenSimMain(sandBoxMode, startLoginServer, physicsEngine, useConfigFile, silent, configFile);
sim.user_accounts = userAccounts;
sim.gridLocalAsset = gridLocalAsset;
sim.m_gridLocalAsset = gridLocalAsset;
sim.StartUp();

View File

@ -53,28 +53,26 @@ namespace OpenSim
public class OpenSimMain : RegionApplicationBase, conscmd_callback
{
public string m_physicsEngine;
protected IGenericConfig localConfig;
public bool m_sandbox = false;
public bool m_sandbox;
public bool m_loginserver;
public bool user_accounts = false;
public bool gridLocalAsset = false;
protected bool configFileSetup = false;
public string m_config;
public bool user_accounts;
public bool m_gridLocalAsset;
protected bool m_useConfigFile;
public string m_configFileName;
protected CommunicationsManager commsManager;
// private CheckSumServer checkServer;
private bool m_silent;
private string m_logFilename = "region-console-" + Guid.NewGuid().ToString() + ".log";
public OpenSimMain(bool sandBoxMode, bool startLoginServer, string physicsEngine, bool useConfigFile, bool silent, string configFile)
public OpenSimMain(bool sandBoxMode, bool startLoginServer, string physicsEngineName, bool useConfigFile, bool silent, string configFileName)
:base( )
{
this.configFileSetup = useConfigFile;
m_useConfigFile = useConfigFile;
m_sandbox = sandBoxMode;
m_loginserver = startLoginServer;
m_physicsEngine = physicsEngine;
m_config = configFile;
m_physicsEngine = physicsEngineName;
m_configFileName = configFileName;
m_silent = silent;
}
@ -86,17 +84,13 @@ namespace OpenSim
{
base.StartUp();
m_log.Verbose("Main.cs:Startup() - Loading configuration");
this.m_networkServersInfo.InitConfig(this.m_sandbox, this.localConfig);
this.localConfig.Close();//for now we can close it as no other classes read from it , but this should change
if (!m_sandbox)
{
m_httpServer.AddStreamHandler(new SimStatusHandler());
}
ScenePresence.LoadTextureFile("avatar-texture.dat");
ClientView.TerrainManager = new TerrainManager(new SecondLife());
this.SetupHttpListener();
m_assetCache = new AssetCache("OpenSim.Region.GridInterfaces.Local.dll", m_networkServersInfo.AssetURL, m_networkServersInfo.AssetSendKey);
AssetCache assetCache = m_assetCache;
assetCache = new AssetCache("OpenSim.Region.GridInterfaces.Local.dll", m_networkServersInfo.AssetURL, m_networkServersInfo.AssetSendKey);
m_inventoryCache = new InventoryCache();
if (m_sandbox)
@ -108,48 +102,6 @@ namespace OpenSim
this.commsManager = new CommunicationsOGS1( m_networkServersInfo, m_httpServer );
}
this.SetupScene();
m_log.Verbose("Main.cs:Startup() - Initialising HTTP server");
//Start http server
m_log.Verbose("Main.cs:Startup() - Starting HTTP server");
m_httpServer.Start();
// Start UDP servers
for (int i = 0; i < m_udpServer.Count; i++)
{
this.m_udpServer[i].ServerListener();
}
}
protected override void Initialize()
{
this.localConfig = new XmlConfig(m_config);
this.localConfig.LoadData();
if (this.configFileSetup)
{
this.SetupFromConfigFile(this.localConfig);
}
}
protected override LogBase CreateLog()
{
return new LogBase(m_logFilename, "Region", this, m_silent);
}
# region Setup methods
protected void SetupScene()
{
IGenericConfig regionConfig;
UDPServer udpServer;
RegionInfo m_regionInfo = new RegionInfo();
AuthenticateSessionsBase authenBase;
string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Regions");
string[] configFiles = Directory.GetFiles(path, "*.xml");
@ -169,7 +121,18 @@ namespace OpenSim
for (int i = 0; i < configFiles.Length; i++)
{
m_regionInfo = new RegionInfo();
Console.WriteLine("Loading region config file");
IGenericConfig regionConfig = new XmlConfig(configFiles[i]);
RegionInfo regionInfo = new RegionInfo();
regionConfig.LoadData();
regionInfo.InitConfig(this.m_sandbox, regionConfig);
regionConfig.Close();
AuthenticateSessionsBase authenBase;
if (m_sandbox)
{
AuthenticateSessionsBase authen = new AuthenticateSessionsBase(); // new AuthenticateSessionsLocal();
@ -182,28 +145,23 @@ namespace OpenSim
this.AuthenticateSessionsHandler.Add(authen);
authenBase = authen;
}
Console.WriteLine("Loading region config file");
regionConfig = new XmlConfig(configFiles[i]);
regionConfig.LoadData();
m_regionInfo.InitConfig(this.m_sandbox, regionConfig);
regionConfig.Close();
udpServer = new UDPServer(m_regionInfo.InternalEndPoint.Port, m_assetCache, this.m_inventoryCache, this.m_log, authenBase);
UDPServer udpServer = new UDPServer(regionInfo.InternalEndPoint.Port, assetCache, this.m_inventoryCache, this.m_log, authenBase);
m_udpServer.Add(udpServer);
this.m_regionData.Add(m_regionInfo);
m_udpServers.Add(udpServer);
m_regionData.Add(regionInfo);
StorageManager tmpStoreManager = new StorageManager("OpenSim.DataStore.NullStorage.dll", m_regionInfo.DataStore, m_regionInfo.RegionName);
StorageManager tmpStoreManager = GetStoreManager(regionInfo);
Scene scene = new Scene( m_regionInfo, authenBase, commsManager, m_assetCache, tmpStoreManager, m_httpServer);
this.m_localWorld.Add(scene);
Scene scene = new Scene(regionInfo, authenBase, commsManager, assetCache, tmpStoreManager, m_httpServer);
m_localWorld.Add(scene);
udpServer.LocalWorld = scene;
scene.LoadStorageDLL("OpenSim.Region.Storage.LocalStorageDb4o.dll"); //all these dll names shouldn't be hard coded.
scene.LoadWorldMap();
PhysicsScene physicsScene = GetPhysicsScene( m_physicsEngine );
PhysicsScene physicsScene = GetPhysicsScene(m_physicsEngine);
scene.PhysScene = physicsScene;
scene.PhysScene.SetTerrain(scene.Terrain.getHeights1D());
@ -226,8 +184,46 @@ namespace OpenSim
scene.performParcelPrimCountUpdate();
scene.StartTimer();
}
// Start UDP servers
for (int i = 0; i < m_udpServers.Count; i++)
{
this.m_udpServers[i].ServerListener();
}
}
protected override StorageManager GetStoreManager(RegionInfo regionInfo)
{
return new StorageManager("OpenSim.DataStore.NullStorage.dll", regionInfo.DataStore, regionInfo.RegionName);
}
protected override void Initialize()
{
m_log.Verbose("Loading Configuration [{0}]", m_configFileName);
IGenericConfig localConfig = new XmlConfig(m_configFileName);
localConfig.LoadData();
if (m_useConfigFile)
{
SetupFromConfigFile(localConfig);
}
m_networkServersInfo.InitConfig(m_sandbox, localConfig);
m_httpServerPort = m_networkServersInfo.HttpListenerPort;
localConfig.Close();
}
protected override LogBase CreateLog()
{
return new LogBase(m_logFilename, "Region", this, m_silent);
}
# region Setup methods
protected override PhysicsScene GetPhysicsScene( )
{
return GetPhysicsScene( m_physicsEngine );
@ -256,16 +252,6 @@ namespace OpenSim
}
}
protected void SetupHttpListener()
{
m_httpServer = new BaseHttpServer(this.m_networkServersInfo.HttpListenerPort); //regionData[0].IPListenPort);
if (!this.m_sandbox)
{
m_httpServer.AddStreamHandler( new SimStatusHandler() );
}
}
protected void ConnectToRemoteGridServer()
{
@ -330,12 +316,12 @@ namespace OpenSim
attri = configData.GetAttribute("LocalAssets");
if ((attri == "") || ((attri != "false") && (attri != "true")))
{
this.gridLocalAsset = false;
this.m_gridLocalAsset = false;
configData.SetAttribute("LocalAssets", "false");
}
else if (attri == "true")
{
this.gridLocalAsset = Convert.ToBoolean(attri);
this.m_gridLocalAsset = Convert.ToBoolean(attri);
}

View File

@ -38,6 +38,7 @@ using OpenSim.Physics.Manager;
using OpenSim.Region.Caches;
using OpenSim.Region.Environment;
using libsecondlife;
using OpenSim.Region.Environment.Scenes;
namespace OpenSim.Region.ClientStack
{
@ -49,10 +50,11 @@ namespace OpenSim.Region.ClientStack
protected DateTime m_startuptime;
protected NetworkServersInfo m_networkServersInfo;
protected List<UDPServer> m_udpServer = new List<UDPServer>();
protected List<UDPServer> m_udpServers = new List<UDPServer>();
protected List<RegionInfo> m_regionData = new List<RegionInfo>();
protected List<IWorld> m_localWorld = new List<IWorld>();
protected BaseHttpServer m_httpServer;
protected int m_httpServerPort;
protected List<AuthenticateSessionsBase> AuthenticateSessionsHandler = new List<AuthenticateSessionsBase>();
protected LogBase m_log;
@ -72,20 +74,26 @@ namespace OpenSim.Region.ClientStack
StartLog();
ScenePresence.LoadTextureFile("avatar-texture.dat");
m_httpServer = new BaseHttpServer( m_httpServerPort );
m_log.Verbose("Starting HTTP server");
m_httpServer.Start();
}
protected abstract void Initialize();
private void StartLog()
{
LogBase logBase = CreateLog();
m_log = logBase;
m_log = CreateLog();
MainLog.Instance = m_log;
}
protected abstract LogBase CreateLog();
protected abstract PhysicsScene GetPhysicsScene( );
protected abstract StorageManager GetStoreManager(RegionInfo regionInfo);
protected PhysicsScene GetPhysicsScene(string engine)
{
PhysicsPluginManager physicsPluginManager;

View File

@ -16,6 +16,7 @@ using OpenSim.Region.GridInterfaces.Local;
using System.Timers;
using OpenSim.Region.Environment.Scenes;
using OpenSim.Framework.Data;
using OpenSim.Region.Environment;
namespace SimpleApp
{
@ -34,42 +35,38 @@ namespace SimpleApp
protected override void Initialize()
{
m_httpServerPort = 9000;
}
public void Run()
{
base.StartUp();
string ipaddr = "127.0.0.1";
MainLog.Instance = m_log;
m_circuitManager = new AuthenticateSessionsBase();
InventoryCache inventoryCache = new InventoryCache();
LocalAssetServer assetServer = new LocalAssetServer();
assetServer.SetServerInfo("http://" + ipaddr + ":8003/", "");
assetServer.SetServerInfo("http://localhost:8003/", "");
AssetCache assetCache = new AssetCache(assetServer);
ScenePresence.LoadTextureFile("avatar-texture.dat");
ScenePresence.PhysicsEngineFlying = true;
IPEndPoint internalEndPoint = new IPEndPoint(IPAddress.Parse(ipaddr), 9000);
IPEndPoint internalEndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 9000);
RegionInfo regionInfo = new RegionInfo(1000, 1000, internalEndPoint, "localhost");
UDPServer udpServer = new UDPServer(internalEndPoint.Port, assetCache, inventoryCache, m_log, m_circuitManager);
PacketServer packetServer = new PacketServer(udpServer);
BaseHttpServer httpServer = new BaseHttpServer(internalEndPoint.Port);
CommunicationsLocal communicationsManager = new CommunicationsLocal(m_networkServersInfo, m_httpServer);
CommunicationsLocal communicationsManager = new CommunicationsLocal(m_networkServersInfo, httpServer);
StorageManager storeMan = GetStoreManager(regionInfo);
RegionInfo regionInfo = new RegionInfo(1000, 1000, internalEndPoint, ipaddr);
OpenSim.Region.Environment.StorageManager storeMan = new OpenSim.Region.Environment.StorageManager("OpenSim.DataStore.NullStorage.dll", "simpleapp.yap", "simpleapp");
m_world = new MyWorld( regionInfo, m_circuitManager, communicationsManager, assetCache, storeMan, httpServer);
m_world = new MyWorld( regionInfo, m_circuitManager, communicationsManager, assetCache, storeMan, m_httpServer);
m_world.PhysScene = GetPhysicsScene( );
m_world.LoadWorldMap();
@ -78,7 +75,7 @@ namespace SimpleApp
udpServer.LocalWorld = m_world;
httpServer.Start();
m_httpServer.Start();
udpServer.ServerListener();
UserProfileData masterAvatar = communicationsManager.UserServer.SetupMasterUser("Test", "User", "test");
@ -105,6 +102,11 @@ namespace SimpleApp
}
protected override StorageManager GetStoreManager(RegionInfo regionInfo)
{
return new StorageManager("OpenSim.DataStore.NullStorage.dll", "simpleapp.yap", "simpleapp");
}
protected override PhysicsScene GetPhysicsScene( )
{
return GetPhysicsScene("basicphysics");
@ -128,8 +130,7 @@ namespace SimpleApp
{
Program app = new Program();
//app.StartUp();
app.Run();
app.StartUp();
}
}
}