OpenSim SwInit

From OpenSimulator

Jump to: navigation, search


What is OpenSimulator SwInit?

This is a simplified view of the initialization of OpenSimulator shown just below. We will go into detail on this page, but lets start slowly.

All of the initialization of OpenSim.exe up to the mainloop is either in Application.cs or called from Application.cs. This important file can be found in ../OpenSim/Region/Application and is the place to start when studying how OpenSim.exe works.

using System;
using OpenSim.Framework.Console;
using OpenSim.Region.Environment.Scenes;
using Nini.config;
namespace OpenSimulator
{
   public class Application
   {   
       [STAThread]
       public static void Main(string[] args)
       {
           ...
           Console.WriteLine("Starting...\n");
           source.AddSwitch("Startup", ...)
           //"inifile","configfile","gridmode","physics","config","noverbose"
           OpenSimMain sim = new OpenSimMain(source);
           sim.StartUp();
           while (true)
           {
               MainLog.Instance.MainLogPrompt();
           }
       }
   }
}

Execution of the simulator begins at Main(). There are a number of Console.WriteLine (like a printf) sending things like "Starting...\n" which are viewable on the console from which OpenSim.exe was started.

There are initializations and instantiations of various classes and finally a main loop that waits for connections on various ports both UDP and TCP along with a console that waits for system control input.

So, here we go as we analyze Application.cs and the things it calls.

Shortly after beginning Main(), we call into IsEnvironmentSupported [./OpenSim/Framework/Utilities/Util.cs] to check for a couple of OS variations. At that point, a series of members (like global variables) are initialized such as

A series of source.AddSwitch("Startup",...) for half a dozen strings and called next to process the various command line arguments such as -gridmode -gridmode and others.

Next is an innocent statement that causes all manner of important things to happen, and it is:

 OpenSimMain sim = new OpenSimMain(source);

This statement sends us off to OpenSimMain.cs to "public class OpenSimMain". See this file at ../OpenSim/Region/Application/. In this class, we begin a series of instantiations for List<UDPServer>, List<RegionInfo>, List<IScene] and open the "region-console-*" log file for writing.

Sometime after that, we return to OpenSim.Application where we call the routine, sim.StartUp(). The routine sim.StartUp() is in OpenSimMain at about line 67. In this routine, we instantiate an m_log = new LogBase and WriteLine the "======================================".

Now we call base.StartUp() which gets us to "virtual public void StartUp()" in RegionApplicationBase.cs and instantiate a ClientView.TerrainManager = new TerrainManager(new SecondLife() ) where we instantiate three members, m_networkServersInfo, m_httpServerPort & m_assetCache.

Right after that we invoke OpenSimMain(IConfigSource configSource) : base() and this sends us to RegionApplicationBase.cs where we run its Startup() class.

At this point, we have gotten to "while(true) { MainLog.Instance.MainLogPrompt(); } and we should be in the main loop.

Personal tools
About This Wiki