* worked a little bit more on straigthening the startup procedure out

tourmaline
lbsa71 2007-03-28 05:27:20 +00:00
parent 24b27487c0
commit d66ef8f428
5 changed files with 161 additions and 190 deletions

View File

@ -63,42 +63,64 @@ namespace OpenSim
private System.Timers.Timer timer1 = new System.Timers.Timer();
private string ConfigDll = "OpenSim.Config.SimConfigDb4o.dll";
public string _physicsEngine = "basicphysics";
public bool sandbox = false;
public bool loginserver = false;
public string m_physicsEngine;
public bool m_sandbox = false;
public bool m_loginserver;
protected ConsoleBase m_console;
public OpenSimMain()
public OpenSimMain( bool sandBoxMode, bool startLoginServer, string physicsEngine )
{
m_sandbox = sandBoxMode;
m_loginserver = startLoginServer;
m_physicsEngine = physicsEngine;
m_console = new ConsoleBase("region-console.log", "Region", this);
OpenSim.Framework.Console.MainConsole.Instance = m_console;
}
public override void StartUp()
{
OpenSimRoot.Instance.GridServers = new Grid();
if ( m_sandbox )
{
OpenSimRoot.Instance.GridServers.AssetDll = "OpenSim.GridInterfaces.Local.dll";
OpenSimRoot.Instance.GridServers.GridDll = "OpenSim.GridInterfaces.Local.dll";
m_console.WriteLine("Starting in Sandbox mode");
}
else
{
OpenSimRoot.Instance.GridServers.AssetDll = "OpenSim.GridInterfaces.Remote.dll";
OpenSimRoot.Instance.GridServers.GridDll = "OpenSim.GridInterfaces.Remote.dll";
m_console.WriteLine("Starting in Grid mode");
}
OpenSimRoot.Instance.GridServers.Initialise();
OpenSimRoot.Instance.startuptime = DateTime.Now;
OpenSimRoot.Instance.AssetCache = new AssetCache(OpenSimRoot.Instance.GridServers.AssetServer);
OpenSimRoot.Instance.InventoryCache = new InventoryCache();
// We check our local database first, then the grid for config options
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Main.cs:Startup() - Loading configuration");
m_console.WriteLine("Main.cs:Startup() - Loading configuration");
OpenSimRoot.Instance.Cfg = this.LoadConfigDll(this.ConfigDll);
OpenSimRoot.Instance.Cfg.InitConfig(this.sandbox);
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Main.cs:Startup() - Contacting gridserver");
OpenSimRoot.Instance.Cfg.InitConfig(this.m_sandbox);
m_console.WriteLine("Main.cs:Startup() - Contacting gridserver");
OpenSimRoot.Instance.Cfg.LoadFromGrid();
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Main.cs:Startup() - We are " + OpenSimRoot.Instance.Cfg.RegionName + " at " + OpenSimRoot.Instance.Cfg.RegionLocX.ToString() + "," + OpenSimRoot.Instance.Cfg.RegionLocY.ToString());
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Initialising world");
m_console.WriteLine("Main.cs:Startup() - We are " + OpenSimRoot.Instance.Cfg.RegionName + " at " + OpenSimRoot.Instance.Cfg.RegionLocX.ToString() + "," + OpenSimRoot.Instance.Cfg.RegionLocY.ToString());
m_console.WriteLine("Initialising world");
OpenSimRoot.Instance.LocalWorld = new World(OpenSimRoot.Instance.ClientThreads, OpenSimRoot.Instance.Cfg.RegionHandle, OpenSimRoot.Instance.Cfg.RegionName, OpenSimRoot.Instance.Cfg);
OpenSimRoot.Instance.LocalWorld.LandMap = OpenSimRoot.Instance.Cfg.LoadWorld();
this.physManager = new OpenSim.Physics.Manager.PhysicsManager();
this.physManager.LoadPlugins();
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Main.cs:Startup() - Starting up messaging system");
OpenSimRoot.Instance.LocalWorld.PhysScene = this.physManager.GetPhysicsScene(this._physicsEngine); //should be reading from the config file what physics engine to use
m_console.WriteLine("Main.cs:Startup() - Starting up messaging system");
OpenSimRoot.Instance.LocalWorld.PhysScene = this.physManager.GetPhysicsScene(this.m_physicsEngine); //should be reading from the config file what physics engine to use
OpenSimRoot.Instance.LocalWorld.PhysScene.SetTerrain(OpenSimRoot.Instance.LocalWorld.LandMap);
OpenSimRoot.Instance.GridServers.AssetServer.SetServerInfo(OpenSimRoot.Instance.Cfg.AssetURL, OpenSimRoot.Instance.Cfg.AssetSendKey);
@ -107,20 +129,26 @@ namespace OpenSim
OpenSimRoot.Instance.LocalWorld.LoadStorageDLL("OpenSim.Storage.LocalStorageDb4o.dll"); //all these dll names shouldn't be hard coded.
OpenSimRoot.Instance.LocalWorld.LoadPrimsFromStorage();
if (this.sandbox)
if ( m_sandbox)
{
OpenSimRoot.Instance.AssetCache.LoadDefaultTextureSet();
}
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Main.cs:Startup() - Starting CAPS HTTP server");
m_console.WriteLine("Main.cs:Startup() - Starting CAPS HTTP server");
OpenSimRoot.Instance.HttpServer = new SimCAPSHTTPServer(OpenSimRoot.Instance.GridServers.GridServer, OpenSimRoot.Instance.Cfg.IPListenPort);
OpenSimRoot.Instance.HttpServer.AddRestHandler("Admin", new AdminWebFront("Admin", OpenSimRoot.Instance.LocalWorld));
if ( m_loginserver && m_sandbox)
{
LoginServer loginServer = new LoginServer(OpenSimRoot.Instance.GridServers.GridServer, OpenSimRoot.Instance.Cfg.IPListenAddr, OpenSimRoot.Instance.Cfg.IPListenPort);
loginServer.Startup();
}
MainServerListener();
timer1.Enabled = true;
timer1.Interval = 100;
timer1.Elapsed += new ElapsedEventHandler(this.Timer1Tick);
MainServerListener();
}
private SimConfig LoadConfigDll(string dllName)
@ -185,21 +213,21 @@ namespace OpenSim
private void MainServerListener()
{
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Main.cs:MainServerListener() - New thread started");
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Main.cs:MainServerListener() - Opening UDP socket on " + OpenSimRoot.Instance.Cfg.IPListenAddr + ":" + OpenSimRoot.Instance.Cfg.IPListenPort);
m_console.WriteLine("Main.cs:MainServerListener() - New thread started");
m_console.WriteLine("Main.cs:MainServerListener() - Opening UDP socket on " + OpenSimRoot.Instance.Cfg.IPListenAddr + ":" + OpenSimRoot.Instance.Cfg.IPListenPort);
ServerIncoming = new IPEndPoint(IPAddress.Any, OpenSimRoot.Instance.Cfg.IPListenPort);
Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
Server.Bind(ServerIncoming);
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Main.cs:MainServerListener() - UDP socket bound, getting ready to listen");
m_console.WriteLine("Main.cs:MainServerListener() - UDP socket bound, getting ready to listen");
ipeSender = new IPEndPoint(IPAddress.Any, 0);
epSender = (EndPoint)ipeSender;
ReceivedData = new AsyncCallback(this.OnReceivedData);
Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Main.cs:MainServerListener() - Listening...");
m_console.WriteLine("Main.cs:MainServerListener() - Listening...");
}
@ -236,14 +264,14 @@ namespace OpenSim
public override void Shutdown()
{
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Main.cs:Shutdown() - Closing all threads");
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Main.cs:Shutdown() - Killing listener thread");
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Main.cs:Shutdown() - Killing clients");
m_console.WriteLine("Main.cs:Shutdown() - Closing all threads");
m_console.WriteLine("Main.cs:Shutdown() - Killing listener thread");
m_console.WriteLine("Main.cs:Shutdown() - Killing clients");
// IMPLEMENT THIS
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Main.cs:Shutdown() - Closing console and terminating");
m_console.WriteLine("Main.cs:Shutdown() - Closing console and terminating");
OpenSimRoot.Instance.LocalWorld.Close();
OpenSimRoot.Instance.GridServers.Close();
OpenSim.Framework.Console.MainConsole.Instance.Close();
m_console.Close();
Environment.Exit(0);
}
@ -271,7 +299,7 @@ namespace OpenSim
break;
case "shutdown":
OpenSimRoot.Instance.Shutdown();
Shutdown();
break;
}
}

View File

@ -44,20 +44,5 @@ namespace OpenSim
public OpenSimApplication Application;
public bool Sandbox = false;
public void StartUp()
{
if (this.Application != null)
{
this.Application.StartUp();
}
}
public void Shutdown()
{
if (this.Application != null)
{
this.Application.Shutdown();
}
}
}
}

View File

@ -35,33 +35,6 @@ Global
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectDependencies) = postSolution
({B9D6A5F0-3BD2-4161-8AF1-90C03295D4EE}).2 = ({BD7866A4-04BA-47F0-905F-B2359118F5B2})
({B9D6A5F0-3BD2-4161-8AF1-90C03295D4EE}).3 = ({4B0A7290-36C2-4C74-B9B4-07775B031CF2})
({A6463B2D-0956-4680-9D03-082199779C66}).5 = ({BD7866A4-04BA-47F0-905F-B2359118F5B2})
({A6463B2D-0956-4680-9D03-082199779C66}).6 = ({4B0A7290-36C2-4C74-B9B4-07775B031CF2})
({98EC7DD5-BAB2-4678-AEA1-7C2B27B27BC9}).4 = ({4B0A7290-36C2-4C74-B9B4-07775B031CF2})
({76C00C0A-1AEF-49C9-8E4E-19A529B364E8}).3 = ({BD7866A4-04BA-47F0-905F-B2359118F5B2})
({76C00C0A-1AEF-49C9-8E4E-19A529B364E8}).4 = ({4B0A7290-36C2-4C74-B9B4-07775B031CF2})
({55969A66-0E92-4F76-BFF6-2256C6A5CAF7}).4 = ({BD7866A4-04BA-47F0-905F-B2359118F5B2})
({55969A66-0E92-4F76-BFF6-2256C6A5CAF7}).5 = ({4B0A7290-36C2-4C74-B9B4-07775B031CF2})
({0CE4ED02-8BB2-439C-8225-E42F2D661D44}).4 = ({4B0A7290-36C2-4C74-B9B4-07775B031CF2})
({F23A90E8-FDED-4D8C-A1B9-2ABE0A8C8EB2}).2 = ({2EAB18A1-8187-4C79-9947-A671F9C007D9})
({E168B13F-8D18-43E7-8546-C0EC1899579F}).2 = ({2EAB18A1-8187-4C79-9947-A671F9C007D9})
({8B0B16BC-D9D0-4200-8FEF-6B12AA896EC1}).5 = ({BD7866A4-04BA-47F0-905F-B2359118F5B2})
({8B0B16BC-D9D0-4200-8FEF-6B12AA896EC1}).6 = ({4B0A7290-36C2-4C74-B9B4-07775B031CF2})
({8B0B16BC-D9D0-4200-8FEF-6B12AA896EC1}).7 = ({2EAB18A1-8187-4C79-9947-A671F9C007D9})
({8B0B16BC-D9D0-4200-8FEF-6B12AA896EC1}).8 = ({ADD974E2-994C-4998-864E-4B54D8AD5F00})
({ADD974E2-994C-4998-864E-4B54D8AD5F00}).5 = ({BD7866A4-04BA-47F0-905F-B2359118F5B2})
({ADD974E2-994C-4998-864E-4B54D8AD5F00}).6 = ({4B0A7290-36C2-4C74-B9B4-07775B031CF2})
({ADD974E2-994C-4998-864E-4B54D8AD5F00}).7 = ({2EAB18A1-8187-4C79-9947-A671F9C007D9})
({ADD974E2-994C-4998-864E-4B54D8AD5F00}).8 = ({B9D6A5F0-3BD2-4161-8AF1-90C03295D4EE})
({2EAB18A1-8187-4C79-9947-A671F9C007D9}).3 = ({BD7866A4-04BA-47F0-905F-B2359118F5B2})
({2EAB18A1-8187-4C79-9947-A671F9C007D9}).4 = ({4B0A7290-36C2-4C74-B9B4-07775B031CF2})
({CBC22F47-9CF2-4748-B6C6-85CDAB267554}).4 = ({BD7866A4-04BA-47F0-905F-B2359118F5B2})
({CBC22F47-9CF2-4748-B6C6-85CDAB267554}).5 = ({4B0A7290-36C2-4C74-B9B4-07775B031CF2})
({0EF13F92-86F1-403D-882A-AA9DD4421B32}).3 = ({2EAB18A1-8187-4C79-9947-A671F9C007D9})
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B9D6A5F0-3BD2-4161-8AF1-90C03295D4EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B9D6A5F0-3BD2-4161-8AF1-90C03295D4EE}.Debug|Any CPU.Build.0 = Debug|Any CPU

View File

@ -8,68 +8,49 @@ namespace OpenSim
{
public class RegionServer : OpenSimMain
{
public RegionServer( ) : base( false, false, String.Empty )
{
}
[STAThread]
public static void Main(string[] args)
{
Console.WriteLine("OpenSim " + VersionInfo.Version + "\n");
Console.WriteLine("Starting...\n");
//OpenSimRoot.instance = new OpenSimRoot();
OpenSimMain sim = new OpenSimMain();
OpenSimRoot.Instance.Application = sim;
sim.sandbox = false;
sim.loginserver = false;
sim._physicsEngine = "basicphysics";
bool sandBoxMode = false;
bool startLoginServer = false;
string physicsEngine = "basicphysics";
bool allowFlying = false;
for (int i = 0; i < args.Length; i++)
{
if (args[i] == "-sandbox")
{
sim.sandbox = true;
OpenSimRoot.Instance.Sandbox = true;
sandBoxMode = true;
}
if (args[i] == "-loginserver")
{
sim.loginserver = true;
startLoginServer = true;
}
if (args[i] == "-realphysx")
{
sim._physicsEngine = "RealPhysX";
OpenSim.world.Avatar.PhysicsEngineFlying = true;
physicsEngine = "RealPhysX";
}
if (args[i] == "-ode")
{
sim._physicsEngine = "OpenDynamicsEngine";
OpenSim.world.Avatar.PhysicsEngineFlying = true;
physicsEngine = "OpenDynamicsEngine";
allowFlying = true;
}
}
OpenSimMain sim = new OpenSimMain( sandBoxMode, startLoginServer, physicsEngine );
OpenSimRoot.Instance.Application = sim;
OpenSimRoot.Instance.Sandbox = sandBoxMode;
OpenSim.world.Avatar.PhysicsEngineFlying = allowFlying;
OpenSimRoot.Instance.GridServers = new Grid();
if (sim.sandbox)
{
OpenSimRoot.Instance.GridServers.AssetDll = "OpenSim.GridInterfaces.Local.dll";
OpenSimRoot.Instance.GridServers.GridDll = "OpenSim.GridInterfaces.Local.dll";
OpenSimRoot.Instance.GridServers.Initialise();
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Starting in Sandbox mode");
}
else
{
OpenSimRoot.Instance.GridServers.AssetDll = "OpenSim.GridInterfaces.Remote.dll";
OpenSimRoot.Instance.GridServers.GridDll = "OpenSim.GridInterfaces.Remote.dll";
OpenSimRoot.Instance.GridServers.Initialise();
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Starting in Grid mode");
}
OpenSimRoot.Instance.StartUp();
if (sim.loginserver && sim.sandbox)
{
LoginServer loginServer = new LoginServer(OpenSimRoot.Instance.GridServers.GridServer, OpenSimRoot.Instance.Cfg.IPListenAddr, OpenSimRoot.Instance.Cfg.IPListenPort);
loginServer.Startup();
}
sim.StartUp();
while (true)
{

View File

@ -1,4 +1,4 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectType>Local</ProjectType>
<ProductVersion>8.0.50727</ProductVersion>
@ -6,7 +6,8 @@
<ProjectGuid>{B9D6A5F0-3BD2-4161-8AF1-90C03295D4EE}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ApplicationIcon></ApplicationIcon>
<ApplicationIcon>
</ApplicationIcon>
<AssemblyKeyContainerName>
</AssemblyKeyContainerName>
<AssemblyName>OpenSim.Servers</AssemblyName>
@ -15,9 +16,11 @@
<DefaultTargetSchema>IE50</DefaultTargetSchema>
<DelaySign>false</DelaySign>
<OutputType>Library</OutputType>
<AppDesignerFolder></AppDesignerFolder>
<AppDesignerFolder>
</AppDesignerFolder>
<RootNamespace>OpenSim.Servers</RootNamespace>
<StartupObject></StartupObject>
<StartupObject>
</StartupObject>
<FileUpgradeFlags>
</FileUpgradeFlags>
</PropertyGroup>
@ -28,7 +31,8 @@
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<DocumentationFile></DocumentationFile>
<DocumentationFile>
</DocumentationFile>
<DebugSymbols>True</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>False</Optimize>
@ -37,7 +41,8 @@
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn></NoWarn>
<NoWarn>
</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
@ -46,7 +51,8 @@
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE</DefineConstants>
<DocumentationFile></DocumentationFile>
<DocumentationFile>
</DocumentationFile>
<DebugSymbols>False</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>True</Optimize>
@ -55,18 +61,19 @@
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn></NoWarn>
<NoWarn>
</NoWarn>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" >
<Reference Include="System">
<HintPath>System.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Xml" >
<Reference Include="System.Xml">
<HintPath>System.Xml.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="libsecondlife.dll" >
<Reference Include="libsecondlife.dll">
<HintPath>..\bin\libsecondlife.dll</HintPath>
<Private>False</Private>
</Reference>
@ -89,9 +96,6 @@
<Compile Include="BaseHttpServer.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="dummy.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
<PropertyGroup>