Common OpenSimulator simulator code
Inheritance: RegionApplicationBase
        private int m_ttl = 2592000; //1 month

        #endregion

        #region IApplicationPlugin Members

        public void Initialize(OpenSimBase openSim)
        {
            IConfig config = openSim.ConfigSource.Source.Configs["ChatLogModule"];
            if (config == null) return;

            m_enabled = config.GetBoolean("Enabled", false) && config.GetString("Backend", "") == "Cassandra12Backend";
            m_debug = config.GetBoolean("Debug", m_debug);
            m_ttl = config.GetInt("TTL", m_ttl);

            Q_INS_TTL = Q_INSERT + m_ttl.ToString() + ";";

            if (m_enabled)
            {
                ExtractSeedNodesFromConfig(config);

                var clusterb = Cluster.Builder();

                foreach (string node in m_seedNodes)
                {
                    if (m_debug) m_log.DebugFormat("[CHATLOG.Cassandra]: Adding seed node {0}", node);
                    clusterb.AddContactPoint(node);
                }

                clusterb.WithDefaultKeyspace(KEYSPACE);
                
                m_cluster = clusterb.Build();
                m_session = m_cluster.Connect();

                ProviderRegistry.Instance.RegisterInterface<IChatMessageLogBackend>(this);
            }
        }
示例#2
0
        public ApplicationPluginInitialiser(OpenSimBase s)
        {
			if (m_log.IsDebugEnabled) {
				m_log.DebugFormat ("{0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
			}
			server = s;
        }
示例#3
0
 public ApplicationPluginInitialiser(OpenSimBase s)
 {
     if (m_log.IsDebugEnabled)
     {
         m_log.DebugFormat("{0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
     }
     server = s;
 }
示例#4
0
 public RegionManager(bool create, OpenSimBase baseOpenSim)
 {
     m_OpenSimBase = baseOpenSim;
     OpenedForCreateRegion = create;
     InitializeComponent();
     if (create)
         tabControl1.SelectedTab = tabPage2;
 }
        public void Initialise(OpenSimBase openSim)
        {
            IConfig config = openSim.ConfigSource.Source.Configs["ChatLogModule"];
            if (config == null) return;

            m_enabled = config.GetString("Backend", "") == "FileBackend";
            m_fileName = config.GetString("File", m_fileName);

            if (m_enabled)
            {
                m_fileWriter = TextWriter.Synchronized(new StreamWriter(m_fileName, true));
                ProviderRegistry.Instance.RegisterInterface<IChatMessageLogBackend>(this);
            }
        }
        public void Initialise (OpenSimBase openSim)
        {
            m_log.DebugFormat("[REGIONMODULES]: Initializing...");
            m_openSim = openSim;
            openSim.ApplicationRegistry.RegisterInterface<IRegionModulesController>(this);

            string id = AddinManager.CurrentAddin.Id;
            int pos = id.LastIndexOf(".");
            if (pos == -1) m_name = id;
            else m_name = id.Substring(pos + 1);

            //ExtensionNodeList list = AddinManager.GetExtensionNodes("/OpenSim/RegionModules");
            // load all the (new) region-module classes
            foreach (TypeExtensionNode node in AddinManager.GetExtensionNodes("/OpenSim/RegionModules"))
            {
                // TODO why does node.Type.isSubclassOf(typeof(ISharedRegionModule)) not work?
                if (node.Type.GetInterface(typeof(ISharedRegionModule).ToString()) != null)
                {
                    m_log.DebugFormat("[REGIONMODULES]: Found shared region module {0}, class {1}", node.Id, node.Type);
                    m_sharedModules.Add(node.Type);
                }
                else if (node.Type.GetInterface(typeof(INonSharedRegionModule).ToString()) != null)
                {
                    m_log.DebugFormat("[REGIONMODULES]: Found non-shared region module {0}, class {1}", node.Id, node.Type);
                    m_nonSharedModules.Add(node.Type);
                }
                else
                    m_log.DebugFormat("[REGIONMODULES]: Found unknown type of module {0}, class {1}", node.Id, node.Type);
            }

            // now we've got all the region-module classes loaded, create one instance of every ISharedRegionModule,
            // initialize and postinitialize it. This Initialise we are in is called before LoadRegion.PostInitialise
            // is called (which loads the regions), so we don't have any regions in the server yet.
            foreach (Type type in m_sharedModules)
            {
                ISharedRegionModule module = (ISharedRegionModule)Activator.CreateInstance(type);
                m_sharedInstances.Add(module);
                module.Initialise(openSim.ConfigSource.Source);
            }

            foreach (ISharedRegionModule module in m_sharedInstances)
            {
                module.PostInitialise();
            }
        }
        // List of shared module instances, for adding to Scenes
        //private List<ISharedRegionModule> m_sharedInstances =
        //        new List<ISharedRegionModule>();

#region IApplicationPlugin implementation

        public void Initialise (OpenSimBase openSim)
        {
            m_openSim = openSim;
            m_openSim.ApplicationRegistry.RegisterInterface<IRegionModulesController>(this);
            m_log.DebugFormat("[REGIONMODULES]: Initializing...");

            // The [Modules] section in the ini file
            IConfig modulesConfig = m_openSim.ConfigSource.Source.Configs["Modules"];
            if (modulesConfig == null)
                modulesConfig = m_openSim.ConfigSource.Source.AddConfig("Modules");

            CompositionContainer moduleContainer = openSim.ModuleContainer;
            IEnumerable<Lazy<object, object>> exportEnumerable = moduleContainer.GetExports(typeof(IRegionModuleBase), null, null);

            foreach (Lazy<object, object> lazyExport in exportEnumerable)
            {
                IDictionary<string, object> metadata = (IDictionary<string, object>)lazyExport.Metadata;
                object nameObj;
                if (metadata.TryGetValue("Name", out nameObj))
                {
                    string name = (string)nameObj;

                    // TODO: Whitelist before we call lazyExport.Value, which instantiates
                    if (lazyExport.Value is ISharedRegionModule)
                    {
                        m_log.DebugFormat("[REGIONMODULES]: Found shared region module {0}", name);
                        m_sharedModules.Add((ISharedRegionModule)lazyExport.Value);
                    }
                    else if (lazyExport.Value is INonSharedRegionModule)
                    {
                        m_log.DebugFormat("[REGIONMODULES]: Found non-shared region module {0}", name);
                        m_nonSharedModules.Add((INonSharedRegionModule)lazyExport.Value);
                    }
                }
            }

            foreach (ISharedRegionModule node in m_sharedModules)
            {
                // OK, we're up and running
                node.Initialise(m_openSim.ConfigSource.Source);
            }
        }
示例#8
0
 public XSimStatusHandler(OpenSimBase sim) 
     : base("GET", "/" + Util.SHA1Hash(sim.osSecret), "XSimStatus", "Simulator XStatus")
 {
     m_opensim = sim;
 }
示例#9
0
 public UXSimStatusHandler(OpenSimBase sim)
 {
     m_opensim = sim;
     osUXStatsURI = sim.userStatsURI;
     
 }
 public ApplicationPluginInitialiser(OpenSimBase s)
 {
     server = s;
 }
示例#11
0
 public XSimStatusHandler(OpenSimBase sim)
     : base("GET", "/" + Util.SHA1Hash(sim.osSecret), "XSimStatus", "Simulator XStatus")
 {
     m_opensim = sim;
 }
示例#12
0
 public DiagnosticsManager(IStatsCollector stats, OpenSimBase baseOpenSim)
 {
     m_OpenSimBase = baseOpenSim;
     m_stats = stats;
     Timer PeriodicDiagnosticsTimer = new Timer(60 * 60 * 1000); // One hour
     PeriodicDiagnosticsTimer.Elapsed += LogDiagnostics;
     PeriodicDiagnosticsTimer.Enabled = true;
     PeriodicDiagnosticsTimer.Start();
 }
        //could move our main function into OpenSimMain and kill this class
        public static void Main(string[] args)
        {
            // First line, hook the appdomain to the crash reporter
            AppDomain.CurrentDomain.UnhandledException +=
                new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            // Add the arguments supplied when running the application to the configuration
            ArgvConfigSource configSource = new ArgvConfigSource(args);

            // Configure Log4Net
            configSource.AddSwitch("Startup", "logconfig");
            string logConfigFile = configSource.Configs["Startup"].GetString("logconfig", String.Empty);
            if (logConfigFile != String.Empty)
            {
                XmlConfigurator.Configure(new System.IO.FileInfo(logConfigFile));
                m_log.InfoFormat("[OPENSIM MAIN]: configured log4net using \"{0}\" as configuration file", 
                                 logConfigFile);
            } 
            else
            {
                XmlConfigurator.Configure();
                m_log.Info("[OPENSIM MAIN]: configured log4net using default OpenSim.exe.config");
            }

            // Check if the system is compatible with OpenSimulator.   
            // Ensures that the minimum system requirements are met
            m_log.Info("Performing compatibility checks... ");
            string supported = String.Empty;
            if (Util.IsEnvironmentSupported(ref supported))
            {
                m_log.Info("Environment is compatible.\n");
            }
            else
            {
                m_log.Warn("Environment is unsupported (" + supported + ")\n");
            }

            // Configure nIni aliases and localles
            Culture.SetCurrentCulture();


            configSource.Alias.AddAlias("On", true);
            configSource.Alias.AddAlias("Off", false);
            configSource.Alias.AddAlias("True", true);
            configSource.Alias.AddAlias("False", false);

            configSource.AddSwitch("Startup", "background");
            configSource.AddSwitch("Startup", "inifile");
            configSource.AddSwitch("Startup", "inimaster");
            configSource.AddSwitch("Startup", "inidirectory");
            configSource.AddSwitch("Startup", "gridmode");
            configSource.AddSwitch("Startup", "physics");
            configSource.AddSwitch("Startup", "gui");

            configSource.AddConfig("StandAlone");
            configSource.AddConfig("Network");

            // Check if we're running in the background or not
            bool background = configSource.Configs["Startup"].GetBoolean("background", false);

            // Check if we're saving crashes
            m_saveCrashDumps = configSource.Configs["Startup"].GetBoolean("save_crashes", false);

            // load Crash directory config
            m_crashDir = configSource.Configs["Startup"].GetString("crash_dir", m_crashDir);

            if (background)
            {
                m_sim = new OpenSimBackground(configSource);
                m_sim.Startup();
            }
            else
            {
                m_sim = new OpenSim(configSource);

                m_sim.Startup();

                while (true)
                {
                    try
                    {
                        // Block thread here for input
                        MainConsole.Instance.Prompt();
                    }
                    catch (Exception e)
                    {
                        m_log.ErrorFormat("Command error: {0}", e);
                    }
                }
            }
        }
示例#14
0
        //could move our main function into OpenSimMain and kill this class
        public static void Main(string[] args)
        {
            // First line, hook the appdomain to the crash reporter
            AppDomain.CurrentDomain.UnhandledException +=
                new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);


            // Add the arguments supplied when running the application to the configuration
            ArgvConfigSource configSource = new ArgvConfigSource(args);

            // Configure Log4Net
            configSource.AddSwitch("Startup", "logconfig");
            string logConfigFile = configSource.Configs["Startup"].GetString("logconfig", String.Empty);

            if (logConfigFile != String.Empty)
            {
                XmlConfigurator.Configure(new System.IO.FileInfo(logConfigFile));
                m_log.InfoFormat("[OPENSIM MAIN]: configured log4net using \"{0}\" as configuration file",
                                 logConfigFile);
            }
            else
            {
                XmlConfigurator.Configure();
                m_log.Info("[OPENSIM MAIN]: configured log4net using default OpenSim.exe.config");
            }

            m_log.DebugFormat(
                "[OPENSIM MAIN]: System Locale is {0}", System.Threading.Thread.CurrentThread.CurrentCulture);

            // Increase the number of IOCP threads available. Mono defaults to a tragically low number
            int workerThreads, iocpThreads;

            System.Threading.ThreadPool.GetMaxThreads(out workerThreads, out iocpThreads);
            m_log.InfoFormat("[OPENSIM MAIN]: Runtime gave us {0} worker threads and {1} IOCP threads", workerThreads, iocpThreads);
            if (workerThreads < 500 || iocpThreads < 1000)
            {
                workerThreads = 500;
                iocpThreads   = 1000;
                m_log.Info("[OPENSIM MAIN]: Bumping up to 500 worker threads and 1000 IOCP threads");
                System.Threading.ThreadPool.SetMaxThreads(workerThreads, iocpThreads);
            }

            // Check if the system is compatible with OpenSimulator.
            // Ensures that the minimum system requirements are met
            m_log.Info("Performing compatibility checks... \n");
            string supported = String.Empty;

            if (Util.IsEnvironmentSupported(ref supported))
            {
                m_log.Info("Environment is compatible.\n");
            }
            else
            {
                m_log.Warn("Environment is unsupported (" + supported + ")\n");
            }

            // Configure nIni aliases and localles
            Culture.SetCurrentCulture();


            // Validate that the user has the most basic configuration done
            // If not, offer to do the most basic configuration for them warning them along the way of the importance of
            // reading these files.

            /*
             * m_log.Info("Checking for reguired configuration...\n");
             *
             * bool OpenSim_Ini = (File.Exists(Path.Combine(Util.configDir(), "OpenSim.ini")))
             || (File.Exists(Path.Combine(Util.configDir(), "opensim.ini")))
             || (File.Exists(Path.Combine(Util.configDir(), "openSim.ini")))
             || (File.Exists(Path.Combine(Util.configDir(), "Opensim.ini")));
             ||
             ||bool StanaloneCommon_ProperCased = File.Exists(Path.Combine(Path.Combine(Util.configDir(), "config-include"), "StandaloneCommon.ini"));
             ||bool StanaloneCommon_lowercased = File.Exists(Path.Combine(Path.Combine(Util.configDir(), "config-include"), "standalonecommon.ini"));
             ||bool GridCommon_ProperCased = File.Exists(Path.Combine(Path.Combine(Util.configDir(), "config-include"), "GridCommon.ini"));
             ||bool GridCommon_lowerCased = File.Exists(Path.Combine(Path.Combine(Util.configDir(), "config-include"), "gridcommon.ini"));
             ||
             ||if ((OpenSim_Ini)
             || && (
             || (StanaloneCommon_ProperCased
             || StanaloneCommon_lowercased
             || GridCommon_ProperCased
             || GridCommon_lowerCased
             || )))
             ||{
             || m_log.Info("Required Configuration Files Found\n");
             ||}
             ||else
             ||{
             || MainConsole.Instance = new LocalConsole("Region");
             || string resp = MainConsole.Instance.CmdPrompt(
             ||                         "\n\n*************Required Configuration files not found.*************\n\n   OpenSimulator will not run without these files.\n\nRemember, these file names are Case Sensitive in Linux and Proper Cased.\n1. ./OpenSim.ini\nand\n2. ./config-include/StandaloneCommon.ini \nor\n3. ./config-include/GridCommon.ini\n\nAlso, you will want to examine these files in great detail because only the basic system will load by default. OpenSimulator can do a LOT more if you spend a little time going through these files.\n\n" + ": " + "Do you want to copy the most basic Defaults from standalone?",
             ||                         "yes");
             || if (resp == "yes")
             || {
             ||
             ||         if (!(OpenSim_Ini))
             ||         {
             ||             try
             ||             {
             ||                 File.Copy(Path.Combine(Util.configDir(), "OpenSim.ini.example"),
             ||                           Path.Combine(Util.configDir(), "OpenSim.ini"));
             ||             } catch (UnauthorizedAccessException)
             ||             {
             ||                 MainConsole.Instance.Output("Unable to Copy OpenSim.ini.example to OpenSim.ini, Make sure OpenSim has have the required permissions\n");
             ||             } catch (ArgumentException)
             ||             {
             ||                 MainConsole.Instance.Output("Unable to Copy OpenSim.ini.example to OpenSim.ini, The current directory is invalid.\n");
             ||             } catch (System.IO.PathTooLongException)
             ||             {
             ||                 MainConsole.Instance.Output("Unable to Copy OpenSim.ini.example to OpenSim.ini, the Path to these files is too long.\n");
             ||             } catch (System.IO.DirectoryNotFoundException)
             ||             {
             ||                 MainConsole.Instance.Output("Unable to Copy OpenSim.ini.example to OpenSim.ini, the current directory is reporting as not found.\n");
             ||             } catch (System.IO.FileNotFoundException)
             ||             {
             ||                 MainConsole.Instance.Output("Unable to Copy OpenSim.ini.example to OpenSim.ini, the example is not found, please make sure that the example files exist.\n");
             ||             } catch (System.IO.IOException)
             ||             {
             ||                 // Destination file exists already or a hard drive failure...   ..    so we can just drop this one
             ||                 //MainConsole.Instance.Output("Unable to Copy OpenSim.ini.example to OpenSim.ini, the example is not found, please make sure that the example files exist.\n");
             ||             } catch (System.NotSupportedException)
             ||             {
             ||                 MainConsole.Instance.Output("Unable to Copy OpenSim.ini.example to OpenSim.ini, The current directory is invalid.\n");
             ||             }
             ||
             ||         }
             ||         if (!(StanaloneCommon_ProperCased || StanaloneCommon_lowercased))
             ||         {
             ||             try
             ||             {
             ||                 File.Copy(Path.Combine(Path.Combine(Util.configDir(), "config-include"), "StandaloneCommon.ini.example"),
             ||                           Path.Combine(Path.Combine(Util.configDir(), "config-include"), "StandaloneCommon.ini"));
             ||             }
             ||             catch (UnauthorizedAccessException)
             ||             {
             ||                 MainConsole.Instance.Output("Unable to Copy StandaloneCommon.ini.example to StandaloneCommon.ini, Make sure OpenSim has the required permissions\n");
             ||             }
             ||             catch (ArgumentException)
             ||             {
             ||                 MainConsole.Instance.Output("Unable to Copy StandaloneCommon.ini.example to StandaloneCommon.ini, The current directory is invalid.\n");
             ||             }
             ||             catch (System.IO.PathTooLongException)
             ||             {
             ||                 MainConsole.Instance.Output("Unable to Copy StandaloneCommon.ini.example to StandaloneCommon.ini, the Path to these files is too long.\n");
             ||             }
             ||             catch (System.IO.DirectoryNotFoundException)
             ||             {
             ||                 MainConsole.Instance.Output("Unable to Copy StandaloneCommon.ini.example to StandaloneCommon.ini, the current directory is reporting as not found.\n");
             ||             }
             ||             catch (System.IO.FileNotFoundException)
             ||             {
             ||                 MainConsole.Instance.Output("Unable to Copy StandaloneCommon.ini.example to StandaloneCommon.ini, the example is not found, please make sure that the example files exist.\n");
             ||             }
             ||             catch (System.IO.IOException)
             ||             {
             ||                 // Destination file exists already or a hard drive failure...   ..    so we can just drop this one
             ||                 //MainConsole.Instance.Output("Unable to Copy OpenSim.ini.example to OpenSim.ini, the example is not found, please make sure that the example files exist.\n");
             ||             }
             ||             catch (System.NotSupportedException)
             ||             {
             ||                 MainConsole.Instance.Output("Unable to Copy StandaloneCommon.ini.example to StandaloneCommon.ini, The current directory is invalid.\n");
             ||             }
             ||         }
             || }
             || MainConsole.Instance = null;
             ||}
             */
            configSource.Alias.AddAlias("On", true);
            configSource.Alias.AddAlias("Off", false);
            configSource.Alias.AddAlias("True", true);
            configSource.Alias.AddAlias("False", false);
            configSource.Alias.AddAlias("Yes", true);
            configSource.Alias.AddAlias("No", false);

            configSource.AddSwitch("Startup", "background");
            configSource.AddSwitch("Startup", "inifile");
            configSource.AddSwitch("Startup", "inimaster");
            configSource.AddSwitch("Startup", "inidirectory");
            configSource.AddSwitch("Startup", "physics");
            configSource.AddSwitch("Startup", "gui");
            configSource.AddSwitch("Startup", "console");
            configSource.AddSwitch("Startup", "save_crashes");
            configSource.AddSwitch("Startup", "crash_dir");

            configSource.AddConfig("StandAlone");
            configSource.AddConfig("Network");

            // Check if we're running in the background or not
            bool background = configSource.Configs["Startup"].GetBoolean("background", false);

            // Check if we're saving crashes
            m_saveCrashDumps = configSource.Configs["Startup"].GetBoolean("save_crashes", false);

            // load Crash directory config
            m_crashDir = configSource.Configs["Startup"].GetString("crash_dir", m_crashDir);

            if (background)
            {
                m_sim = new OpenSimBackground(configSource);
                m_sim.Startup();
            }
            else
            {
                m_sim = new OpenSim(configSource);

                m_sim.Startup();

                while (true)
                {
                    try
                    {
                        // Block thread here for input
                        MainConsole.Instance.Prompt();
                    }
                    catch (Exception e)
                    {
                        m_log.ErrorFormat("Command error: {0}", e);
                    }
                }
            }
        }
示例#15
0
        //could move our main function into OpenSimMain and kill this class
        public static void Main(string[] args)
        {
            // First line, hook the appdomain to the crash reporter
            AppDomain.CurrentDomain.UnhandledException +=
                new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            ServicePointManager.DefaultConnectionLimit = 12;

            // Add the arguments supplied when running the application to the configuration
            ArgvConfigSource configSource = new ArgvConfigSource(args);

            // Configure Log4Net
            configSource.AddSwitch("Startup", "logconfig");
            string logConfigFile = configSource.Configs["Startup"].GetString("logconfig", String.Empty);

            if (logConfigFile != String.Empty)
            {
                XmlConfigurator.Configure(new System.IO.FileInfo(logConfigFile));
                m_log.InfoFormat("[HALCYON MAIN]: configured log4net using \"{0}\" as configuration file",
                                 logConfigFile);
            }
            else
            {
                XmlConfigurator.Configure();
                m_log.Info("[HALCYON MAIN]: configured log4net using default Halcyon.exe.config");
            }

            m_log.Info("Performing compatibility checks... ");
            string supported = String.Empty;

            if (Util.IsEnvironmentSupported(ref supported))
            {
                m_log.Info("Environment is compatible.\n");
            }
            else
            {
                m_log.Warn("Environment is unsupported (" + supported + ")\n");
            }

            // Configure nIni aliases and localles
            Culture.SetCurrentCulture();

            configSource.Alias.AddAlias("On", true);
            configSource.Alias.AddAlias("Off", false);
            configSource.Alias.AddAlias("True", true);
            configSource.Alias.AddAlias("False", false);
            configSource.Alias.AddAlias("Yes", true);
            configSource.Alias.AddAlias("No", false);

            configSource.AddSwitch("Startup", "background");
            configSource.AddSwitch("Startup", "inifile");
            configSource.AddSwitch("Startup", "inimaster");
            configSource.AddSwitch("Startup", "inidirectory");
            configSource.AddSwitch("Startup", "gridmode");
            configSource.AddSwitch("Startup", "physics");
            configSource.AddSwitch("Startup", "gui");
            configSource.AddSwitch("Startup", "console");
            configSource.AddSwitch("Startup", "save_crashes");
            configSource.AddSwitch("Startup", "crash_dir");

            configSource.AddConfig("StandAlone");
            configSource.AddConfig("Network");

            // Check if we're running in the background or not
            bool background = configSource.Configs["Startup"].GetBoolean("background", false);

            // Check if we're saving crashes
            m_saveCrashDumps = configSource.Configs["Startup"].GetBoolean("save_crashes", false);

            // load Crash directory config
            m_crashDir = configSource.Configs["Startup"].GetString("crash_dir", m_crashDir);

            if (background)
            {
                m_sim = new OpenSimBackground(configSource);
                m_sim.Startup();
            }
            else
            {
                m_sim = new OpenSim(configSource);

                m_sim.Startup();

                while (true)
                {
                    try
                    {
                        // Block thread here for input
                        MainConsole.Instance.Prompt();
                    }
                    catch (Exception e)
                    {
                        m_log.ErrorFormat("Command error: {0}", e);
                    }
                }
            }
        }
示例#16
0
        //could move our main function into OpenSimMain and kill this class
        public static void Main(string[] args)
        {
            // First line, hook the appdomain to the crash reporter
            AppDomain.CurrentDomain.UnhandledException +=
                new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            ServicePointManager.DefaultConnectionLimit = 12;

            // Add the arguments supplied when running the application to the configuration
            ArgvConfigSource configSource = new ArgvConfigSource(args);

            // Configure Log4Net
            configSource.AddSwitch("Startup", "logconfig");
            string logConfigFile = configSource.Configs["Startup"].GetString("logconfig", String.Empty);

            if (logConfigFile != String.Empty)
            {
                XmlConfigurator.Configure(new System.IO.FileInfo(logConfigFile));
                m_log.InfoFormat("[OPENSIM MAIN]: configured log4net using \"{0}\" as configuration file",
                                 logConfigFile);
            }
            else
            {
                XmlConfigurator.Configure();
                m_log.Info("[OPENSIM MAIN]: configured log4net using default OpenSim.exe.config");
            }

            m_log.InfoFormat(
                "[OPENSIM MAIN]: System Locale is {0}", System.Threading.Thread.CurrentThread.CurrentCulture);

            string monoThreadsPerCpu = System.Environment.GetEnvironmentVariable("MONO_THREADS_PER_CPU");

            m_log.InfoFormat(
                "[OPENSIM MAIN]: Environment variable MONO_THREADS_PER_CPU is {0}", monoThreadsPerCpu ?? "unset");

            // Verify the Threadpool allocates or uses enough worker and IO completion threads
            // .NET 2.0, workerthreads default to 50 *  numcores
            // .NET 3.0, workerthreads defaults to 250 * numcores
            // .NET 4.0, workerthreads are dynamic based on bitness and OS resources
            // Max IO Completion threads are 1000 on all 3 CLRs
            //
            // Mono 2.10.9 to at least Mono 3.1, workerthreads default to 100 * numcores, iocp threads to 4 * numcores
            int workerThreadsMin = 500;
            int workerThreadsMax = 1000;           // may need further adjustment to match other CLR
            int iocpThreadsMin   = 1000;
            int iocpThreadsMax   = 2000;           // may need further adjustment to match other CLR

            {
                int currentMinWorkerThreads, currentMinIocpThreads;
                System.Threading.ThreadPool.GetMinThreads(out currentMinWorkerThreads, out currentMinIocpThreads);
                m_log.InfoFormat(
                    "[OPENSIM MAIN]: Runtime gave us {0} min worker threads and {1} min IOCP threads",
                    currentMinWorkerThreads, currentMinIocpThreads);
            }

            int workerThreads, iocpThreads;

            System.Threading.ThreadPool.GetMaxThreads(out workerThreads, out iocpThreads);
            m_log.InfoFormat("[OPENSIM MAIN]: Runtime gave us {0} max worker threads and {1} max IOCP threads", workerThreads, iocpThreads);

            if (workerThreads < workerThreadsMin)
            {
                workerThreads = workerThreadsMin;
                m_log.InfoFormat("[OPENSIM MAIN]: Bumping up to max worker threads to {0}", workerThreads);
            }
            if (workerThreads > workerThreadsMax)
            {
                workerThreads = workerThreadsMax;
                m_log.InfoFormat("[OPENSIM MAIN]: Limiting max worker threads to {0}", workerThreads);
            }

            // Increase the number of IOCP threads available.
            // Mono defaults to a tragically low number (24 on 6-core / 8GB Fedora 17)
            if (iocpThreads < iocpThreadsMin)
            {
                iocpThreads = iocpThreadsMin;
                m_log.InfoFormat("[OPENSIM MAIN]: Bumping up max IOCP threads to {0}", iocpThreads);
            }
            // Make sure we don't overallocate IOCP threads and thrash system resources
            if (iocpThreads > iocpThreadsMax)
            {
                iocpThreads = iocpThreadsMax;
                m_log.InfoFormat("[OPENSIM MAIN]: Limiting max IOCP completion threads to {0}", iocpThreads);
            }
            // set the resulting worker and IO completion thread counts back to ThreadPool
            if (System.Threading.ThreadPool.SetMaxThreads(workerThreads, iocpThreads))
            {
                m_log.InfoFormat(
                    "[OPENSIM MAIN]: Threadpool set to {0} max worker threads and {1} max IOCP threads",
                    workerThreads, iocpThreads);
            }
            else
            {
                m_log.Warn("[OPENSIM MAIN]: Threadpool reconfiguration failed, runtime defaults still in effect.");
            }

            // Check if the system is compatible with OpenSimulator.
            // Ensures that the minimum system requirements are met
            string supported = String.Empty;

            if (Util.IsEnvironmentSupported(ref supported))
            {
                m_log.Info("[OPENSIM MAIN]: Environment is supported by OpenSimulator.");
            }
            else
            {
                m_log.Warn("[OPENSIM MAIN]: Environment is not supported by OpenSimulator (" + supported + ")\n");
            }

            // Configure nIni aliases and localles
            Culture.SetCurrentCulture();

            configSource.Alias.AddAlias("On", true);
            configSource.Alias.AddAlias("Off", false);
            configSource.Alias.AddAlias("True", true);
            configSource.Alias.AddAlias("False", false);
            configSource.Alias.AddAlias("Yes", true);
            configSource.Alias.AddAlias("No", false);

            configSource.AddSwitch("Startup", "background");
            configSource.AddSwitch("Startup", "inifile");
            configSource.AddSwitch("Startup", "inimaster");
            configSource.AddSwitch("Startup", "inidirectory");
            configSource.AddSwitch("Startup", "physics");
            configSource.AddSwitch("Startup", "gui");
            configSource.AddSwitch("Startup", "console");
            configSource.AddSwitch("Startup", "save_crashes");
            configSource.AddSwitch("Startup", "crash_dir");

            configSource.AddConfig("StandAlone");
            configSource.AddConfig("Network");

            // Check if we're running in the background or not
            bool background = configSource.Configs["Startup"].GetBoolean("background", false);

            // Check if we're saving crashes
            m_saveCrashDumps = configSource.Configs["Startup"].GetBoolean("save_crashes", false);

            // load Crash directory config
            m_crashDir = configSource.Configs["Startup"].GetString("crash_dir", m_crashDir);

            if (background)
            {
                m_sim = new OpenSimBackground(configSource);
                m_sim.Startup();
            }
            else
            {
                m_sim = new OpenSim(configSource);

                m_sim.Startup();

                while (true)
                {
                    try
                    {
                        // Block thread here for input
                        MainConsole.Instance.Prompt();
                    }
                    catch (Exception e)
                    {
                        m_log.ErrorFormat("Command error: {0}", e);
                    }
                }
            }
        }
示例#17
0
 public UXAgentStatusHandler(OpenSimBase sim)
     : base("GET", "/" + sim.agentStatsURI, "UXAgentStatus", "Agent UXStatus")
 {
     // Save reference to OpenSim region server interface
     m_opensim = sim;
 }
示例#18
0
        public static bool Startup(ArgvConfigSource configSource)
        {
            try
            {
                OpenSimBase m_sim = new OpenSimBase(configSource);
                m_sim.Startup();
            }
            catch (Exception ex)
            {
                if (ex.Message != "Restart") //Internal needs a restart message
                {
                    string mes = "[AURORA]: Aurora has crashed! Error: " + ex + ", Stack trace: " + ex.StackTrace;

                    m_log.Error(mes);
                    handleException(mes, ex);
                }
                return false;
            }
            return true;
        }
示例#19
0
        //could move our main function into OpenSimMain and kill this class
        public static void Main(string[] args)
        {
            // First line, hook the appdomain to the crash reporter
            AppDomain.CurrentDomain.UnhandledException +=
                new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            ServicePointManager.DefaultConnectionLimit = 12;

            // Add the arguments supplied when running the application to the configuration
            ArgvConfigSource configSource = new ArgvConfigSource(args);

            // Configure Log4Net
            configSource.AddSwitch("Startup", "logconfig");
            string logConfigFile = configSource.Configs["Startup"].GetString("logconfig", String.Empty);
            if (logConfigFile != String.Empty)
            {
                XmlConfigurator.Configure(new System.IO.FileInfo(logConfigFile));
                m_log.InfoFormat("[OPENSIM MAIN]: configured log4net using \"{0}\" as configuration file", 
                                 logConfigFile);
            } 
            else
            {
                XmlConfigurator.Configure();
                m_log.Info("[OPENSIM MAIN]: configured log4net using default OpenSim.exe.config");
            }

            m_log.InfoFormat(
                "[OPENSIM MAIN]: System Locale is {0}", System.Threading.Thread.CurrentThread.CurrentCulture);

            string monoThreadsPerCpu = System.Environment.GetEnvironmentVariable("MONO_THREADS_PER_CPU");

            m_log.InfoFormat(
                "[OPENSIM MAIN]: Environment variable MONO_THREADS_PER_CPU is {0}", monoThreadsPerCpu ?? "unset");

            // Verify the Threadpool allocates or uses enough worker and IO completion threads
			// .NET 2.0, workerthreads default to 50 *  numcores
			// .NET 3.0, workerthreads defaults to 250 * numcores
			// .NET 4.0, workerthreads are dynamic based on bitness and OS resources
            // Max IO Completion threads are 1000 on all 3 CLRs
            //
            // Mono 2.10.9 to at least Mono 3.1, workerthreads default to 100 * numcores, iocp threads to 4 * numcores
			int workerThreadsMin = 500;
			int workerThreadsMax = 1000; // may need further adjustment to match other CLR
			int iocpThreadsMin = 1000;
			int iocpThreadsMax = 2000; // may need further adjustment to match other CLR

            {
                int currentMinWorkerThreads, currentMinIocpThreads;
                System.Threading.ThreadPool.GetMinThreads(out currentMinWorkerThreads, out currentMinIocpThreads);
                m_log.InfoFormat(
                    "[OPENSIM MAIN]: Runtime gave us {0} min worker threads and {1} min IOCP threads", 
                    currentMinWorkerThreads, currentMinIocpThreads);
            }

            int workerThreads, iocpThreads;
            System.Threading.ThreadPool.GetMaxThreads(out workerThreads, out iocpThreads);
            m_log.InfoFormat("[OPENSIM MAIN]: Runtime gave us {0} max worker threads and {1} max IOCP threads", workerThreads, iocpThreads);

            if (workerThreads < workerThreadsMin)
            {
                workerThreads = workerThreadsMin;
                m_log.InfoFormat("[OPENSIM MAIN]: Bumping up to max worker threads to {0}",workerThreads);
            }
            if (workerThreads > workerThreadsMax)
            {
                workerThreads = workerThreadsMax;
                m_log.InfoFormat("[OPENSIM MAIN]: Limiting max worker threads to {0}",workerThreads);
            }

			// Increase the number of IOCP threads available.
			// Mono defaults to a tragically low number (24 on 6-core / 8GB Fedora 17)
			if (iocpThreads < iocpThreadsMin)
            {
                iocpThreads = iocpThreadsMin;
                m_log.InfoFormat("[OPENSIM MAIN]: Bumping up max IOCP threads to {0}",iocpThreads);
            }
			// Make sure we don't overallocate IOCP threads and thrash system resources
            if ( iocpThreads > iocpThreadsMax )
            {
                iocpThreads = iocpThreadsMax;
                m_log.InfoFormat("[OPENSIM MAIN]: Limiting max IOCP completion threads to {0}",iocpThreads);
            }
			// set the resulting worker and IO completion thread counts back to ThreadPool
            if ( System.Threading.ThreadPool.SetMaxThreads(workerThreads, iocpThreads) )
			{
	            m_log.InfoFormat(
                    "[OPENSIM MAIN]: Threadpool set to {0} max worker threads and {1} max IOCP threads",
                    workerThreads, iocpThreads);
			}
			else
			{
	            m_log.Warn("[OPENSIM MAIN]: Threadpool reconfiguration failed, runtime defaults still in effect.");				
			}

            // Check if the system is compatible with OpenSimulator.
            // Ensures that the minimum system requirements are met
            string supported = String.Empty;
            if (Util.IsEnvironmentSupported(ref supported))
            {
                m_log.Info("[OPENSIM MAIN]: Environment is supported by OpenSimulator.");
            }
            else
            {
                m_log.Warn("[OPENSIM MAIN]: Environment is not supported by OpenSimulator (" + supported + ")\n");
            }

            // Configure nIni aliases and localles
            Culture.SetCurrentCulture();

            configSource.Alias.AddAlias("On", true);
            configSource.Alias.AddAlias("Off", false);
            configSource.Alias.AddAlias("True", true);
            configSource.Alias.AddAlias("False", false);
            configSource.Alias.AddAlias("Yes", true);
            configSource.Alias.AddAlias("No", false);

            configSource.AddSwitch("Startup", "background");
            configSource.AddSwitch("Startup", "inifile");
            configSource.AddSwitch("Startup", "inimaster");
            configSource.AddSwitch("Startup", "inidirectory");
            configSource.AddSwitch("Startup", "physics");
            configSource.AddSwitch("Startup", "gui");
            configSource.AddSwitch("Startup", "console");
            configSource.AddSwitch("Startup", "save_crashes");
            configSource.AddSwitch("Startup", "crash_dir");

            configSource.AddConfig("StandAlone");
            configSource.AddConfig("Network");

            // Check if we're running in the background or not
            bool background = configSource.Configs["Startup"].GetBoolean("background", false);

            // Check if we're saving crashes
            m_saveCrashDumps = configSource.Configs["Startup"].GetBoolean("save_crashes", false);

            // load Crash directory config
            m_crashDir = configSource.Configs["Startup"].GetString("crash_dir", m_crashDir);           

            if (background)
            {
                m_sim = new OpenSimBackground(configSource);
                m_sim.Startup();
            }
            else
            {                       
                m_sim = new OpenSim(configSource);
                          
                m_sim.Startup();

                while (true)
                {
                    try
                    {
                        // Block thread here for input
                        MainConsole.Instance.Prompt();
                    }
                    catch (Exception e)
                    {
                        m_log.ErrorFormat("Command error: {0}", e);
                    }
                }
            }
        }
        public void Initialize (IOpenSimBase openSim)
        {
            m_openSim = (OpenSimBase)openSim;
            m_openSim.ApplicationRegistry.RegisterInterface<IRegionModulesController>(this);
            //m_log.DebugFormat("[REGIONMODULES]: Initializing...");

            // Who we are
            /*string id = AddinManager.CurrentAddin.Id;

            // Make friendly name
            int pos = id.LastIndexOf(".");
            if (pos == -1)
                m_name = id;
            else
                m_name = id.Substring(pos + 1);

            // The [Modules] section in the ini file
            IConfig modulesConfig =
                    m_openSim.ConfigSource.Configs["Modules"];
            if (modulesConfig == null)
                modulesConfig = m_openSim.ConfigSource.AddConfig("Modules");*/

            // Scan modules and load all that aren't disabled
            m_sharedInstances = Aurora.Framework.AuroraModuleLoader.PickupModules<ISharedRegionModule>();
            /*foreach (TypeExtensionNode node in
                    AddinManager.GetExtensionNodes("/OpenSim/RegionModules"))
            {
                if (node.Type.GetInterface(typeof(ISharedRegionModule).ToString()) != null)
                {
                    // Get the config string
                    string moduleString =
                            modulesConfig.GetString("Setup_" + node.Id, String.Empty);

                    // We have a selector
                    if (moduleString != String.Empty)
                    {
                        // Allow disabling modules even if they don't have
                        // support for it
                        if (moduleString == "disabled")
                            continue;

                        // Split off port, if present
                        string[] moduleParts = moduleString.Split(new char[] { '/' }, 2);
                        // Format is [port/][class]
                        string className = moduleParts[0];
                        if (moduleParts.Length > 1)
                            className = moduleParts[1];

                        // Match the class name if given
                        if (className != String.Empty &&
                                node.Type.ToString() != className)
                            continue;
                    }

                    //m_log.DebugFormat("[REGIONMODULES]: Found shared region module {0}, class {1}", node.Id, node.Type);
                    m_sharedModules.Add(node);
                }
                else if (node.Type.GetInterface(typeof(INonSharedRegionModule).ToString()) != null)
                {
                    // Get the config string
                    string moduleString =
                            modulesConfig.GetString("Setup_" + node.Id, String.Empty);

                    // We have a selector
                    if (moduleString != String.Empty)
                    {
                        // Allow disabling modules even if they don't have
                        // support for it
                        if (moduleString == "disabled")
                            continue;

                        // Split off port, if present
                        string[] moduleParts = moduleString.Split(new char[] { '/' }, 2);
                        // Format is [port/][class]
                        string className = moduleParts[0];
                        if (moduleParts.Length > 1)
                            className = moduleParts[1];

                        // Match the class name if given
                        if (className != String.Empty &&
                                node.Type.ToString() != className)
                            continue;
                    }

                    //m_log.DebugFormat("[REGIONMODULES]: Found non-shared region module {0}, class {1}", node.Id, node.Type);
                    m_nonSharedModules.Add(node);
                }
                else
                    m_log.DebugFormat("[REGIONMODULES]: Found unknown type of module {0}, class {1}", node.Id, node.Type);
            }*/

            /*// Load and init the module. We try a constructor with a port
            // if a port was given, fall back to one without if there is
            // no port or the more specific constructor fails.
            // This will be removed, so that any module capable of using a port
            // must provide a constructor with a port in the future.
            // For now, we do this so migration is easy.
            //
            foreach (TypeExtensionNode node in m_sharedModules)
            {
                ISharedRegionModule module = (ISharedRegionModule)Activator.CreateInstance(
                            node.Type);

                // OK, we're up and running
                m_sharedInstances.Add(module);
                module.Initialise(m_openSim.ConfigSource);
            }*/
            foreach (ISharedRegionModule module in m_sharedInstances)
            {
                module.Initialise(m_openSim.ConfigSource);
            }
        }
 public ApplicationPluginInitialiser(OpenSimBase s)
 {
     server = s;
 }
示例#22
0
        //could move our main function into OpenSimMain and kill this class
        public static void Main(string[] args)
        {
            // First line
            AppDomain.CurrentDomain.UnhandledException +=
                new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            ArgvConfigSource configSource = new ArgvConfigSource(args);

            configSource.AddSwitch("Startup", "logconfig");
            string logConfigFile = configSource.Configs["Startup"].GetString("logconfig", String.Empty);

            if (logConfigFile != String.Empty)
            {
                XmlConfigurator.Configure(new System.IO.FileInfo(logConfigFile));
                m_log.InfoFormat("[OPENSIM MAIN]: configured log4net using \"{0}\" as configuration file",
                                 logConfigFile);
            }
            else
            {
                XmlConfigurator.Configure();
                m_log.Info("[OPENSIM MAIN]: configured log4net using default OpenSim.exe.config");
            }

            m_log.Info("Performing compatibility checks... ");
            string supported = String.Empty;

            if (Util.IsEnvironmentSupported(ref supported))
            {
                m_log.Info("Environment is compatible.\n");
            }
            else
            {
                m_log.Warn("Environment is unsupported (" + supported + ")\n");
            }

            Culture.SetCurrentCulture();


            configSource.Alias.AddAlias("On", true);
            configSource.Alias.AddAlias("Off", false);
            configSource.Alias.AddAlias("True", true);
            configSource.Alias.AddAlias("False", false);

            configSource.AddSwitch("Startup", "background");
            configSource.AddSwitch("Startup", "inifile");
            configSource.AddSwitch("Startup", "inimaster");
            configSource.AddSwitch("Startup", "inidirectory");
            configSource.AddSwitch("Startup", "gridmode");
            configSource.AddSwitch("Startup", "physics");
            configSource.AddSwitch("Startup", "gui");

            configSource.AddConfig("StandAlone");
            configSource.AddConfig("Network");

            bool background = configSource.Configs["Startup"].GetBoolean("background", false);

            m_saveCrashDumps = configSource.Configs["Startup"].GetBoolean("save_crashes", false);
            m_crashDir       = configSource.Configs["Startup"].GetString("crash_dir", m_crashDir);

            if (background)
            {
                m_sim = new OpenSimBackground(configSource);
                m_sim.Startup();
            }
            else
            {
                m_sim = new OpenSim(configSource);

                m_sim.Startup();

                while (true)
                {
                    try
                    {
                        MainConsole.Instance.Prompt();
                    }
                    catch (Exception e)
                    {
                        m_log.ErrorFormat("Command error: {0}", e);
                    }
                }
            }
        }
示例#23
0
 public UXSimStatusHandler(OpenSimBase sim)
     : base("/" + sim.userStatsURI, "UXSimStatus")
 {
     m_opensim = sim;
 }
示例#24
0
        private static bool _IsHandlingException; // Make sure we don't go recursive on ourself

        //could move our main function into OpenSimMain and kill this class
        public static void Main(string[] args)
        {
            // First line, hook the appdomain to the crash reporter
            AppDomain.CurrentDomain.UnhandledException +=
                new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            // Add the arguments supplied when running the application to the configuration
            ArgvConfigSource configSource = new ArgvConfigSource(args);

            // Configure Log4Net
            configSource.AddSwitch("Startup", "logconfig");
            string logConfigFile = configSource.Configs["Startup"].GetString("logconfig", String.Empty);

            if (logConfigFile != String.Empty)
            {
                XmlConfigurator.Configure(new System.IO.FileInfo(logConfigFile));
                m_log.InfoFormat("[OPENSIM MAIN]: configured log4net using \"{0}\" as configuration file",
                                 logConfigFile);
            }
            else
            {
                XmlConfigurator.Configure();
                m_log.Info("[OPENSIM MAIN]: configured log4net using default OpenSim.exe.config");
            }

            // Increase the number of IOCP threads available. Mono defaults to a tragically low number
            int workerThreads, iocpThreads;

            System.Threading.ThreadPool.GetMaxThreads(out workerThreads, out iocpThreads);
            m_log.InfoFormat("[OPENSIM MAIN]: Runtime gave us {0} worker threads and {1} IOCP threads", workerThreads, iocpThreads);
            if (workerThreads < 500 || iocpThreads < 1000)
            {
                workerThreads = 500;
                iocpThreads   = 1000;
                m_log.Info("[OPENSIM MAIN]: Bumping up to 500 worker threads and 1000 IOCP threads");
                System.Threading.ThreadPool.SetMaxThreads(workerThreads, iocpThreads);
            }

            // Check if the system is compatible with OpenSimulator.
            // Ensures that the minimum system requirements are met
            m_log.Info("Performing compatibility checks... \n");
            string supported = String.Empty;

            if (Util.IsEnvironmentSupported(ref supported))
            {
                m_log.Info("Environment is compatible.\n");
            }
            else
            {
                m_log.Warn("Environment is unsupported (" + supported + ")\n");
            }

            // Configure nIni aliases and localles
            Culture.SetCurrentCulture();

            configSource.Alias.AddAlias("On", true);
            configSource.Alias.AddAlias("Off", false);
            configSource.Alias.AddAlias("True", true);
            configSource.Alias.AddAlias("False", false);

            configSource.AddSwitch("Startup", "background");
            configSource.AddSwitch("Startup", "inifile");
            configSource.AddSwitch("Startup", "inimaster");
            configSource.AddSwitch("Startup", "inidirectory");
            configSource.AddSwitch("Startup", "physics");
            configSource.AddSwitch("Startup", "gui");
            configSource.AddSwitch("Startup", "console");

            configSource.AddConfig("StandAlone");
            configSource.AddConfig("Network");

            // Check if we're running in the background or not
            bool background = configSource.Configs["Startup"].GetBoolean("background", false);

            // Check if we're saving crashes
            m_saveCrashDumps = configSource.Configs["Startup"].GetBoolean("save_crashes", false);

            // load Crash directory config
            m_crashDir = configSource.Configs["Startup"].GetString("crash_dir", m_crashDir);

            if (background)
            {
                m_sim = new OpenSimBackground(configSource);
                m_sim.Startup();
            }
            else
            {
                m_sim = new OpenSim(configSource);

                m_sim.Startup();

                while (true)
                {
                    try
                    {
                        // Block thread here for input
                        MainConsole.Instance.Prompt();
                    }
                    catch (Exception e)
                    {
                        m_log.ErrorFormat("Command error: {0}", e);
                    }
                }
            }
        }
示例#25
0
 public UXSimStatusHandler(OpenSimBase sim)
     : base("GET", "/" + sim.userStatsURI, "UXSimStatus", "Simulator UXStatus")
 {
     m_opensim = sim;
 }
        public void Initialise (OpenSimBase openSim)
        {
            m_openSim = openSim;
            m_openSim.ApplicationRegistry.RegisterInterface<IRegionModulesController>(this);
            m_log.DebugFormat("[REGIONMODULES]: Initializing...");

            // Who we are
            string id = AddinManager.CurrentAddin.Id;

            // Make friendly name
            int pos = id.LastIndexOf(".");
            if (pos == -1)
                m_name = id;
            else
                m_name = id.Substring(pos + 1);

            // The [Modules] section in the ini file
            IConfig modulesConfig =
                    m_openSim.ConfigSource.Source.Configs["Modules"];
            if (modulesConfig == null)
                modulesConfig = m_openSim.ConfigSource.Source.AddConfig("Modules");

            Dictionary<RuntimeAddin, IList<int>> loadedModules = new Dictionary<RuntimeAddin, IList<int>>();

            // Scan modules and load all that aren't disabled
            foreach (TypeExtensionNode node in
                    AddinManager.GetExtensionNodes("/OpenSim/RegionModules"))
            {
                IList<int> loadedModuleData;

                if (!loadedModules.ContainsKey(node.Addin))
                    loadedModules.Add(node.Addin, new List<int> { 0, 0, 0 });

                loadedModuleData = loadedModules[node.Addin];
                      
                if (node.Type.GetInterface(typeof(ISharedRegionModule).ToString()) != null)
                {
                    if (CheckModuleEnabled(node, modulesConfig))
                    {
                        m_log.DebugFormat("[REGIONMODULES]: Found shared region module {0}, class {1}", node.Id, node.Type);
                        m_sharedModules.Add(node);
                        loadedModuleData[0]++;
                    }
                }
                else if (node.Type.GetInterface(typeof(INonSharedRegionModule).ToString()) != null)
                {
                    if (CheckModuleEnabled(node, modulesConfig))
                    {
                        m_log.DebugFormat("[REGIONMODULES]: Found non-shared region module {0}, class {1}", node.Id, node.Type);
                        m_nonSharedModules.Add(node);
                        loadedModuleData[1]++;
                    }
                }
                else
                {
                    m_log.WarnFormat("[REGIONMODULES]: Found unknown type of module {0}, class {1}", node.Id, node.Type);
                    loadedModuleData[2]++;
                }
            }

            foreach (KeyValuePair<RuntimeAddin, IList<int>> loadedModuleData in loadedModules)
            {
                m_log.InfoFormat(
                    "[REGIONMODULES]: From plugin {0}, (version {1}), loaded {2} modules, {3} shared, {4} non-shared {5} unknown",
                    loadedModuleData.Key.Id, 
                    loadedModuleData.Key.Version,
                    loadedModuleData.Value[0] + loadedModuleData.Value[1] + loadedModuleData.Value[2],
                    loadedModuleData.Value[0], loadedModuleData.Value[1], loadedModuleData.Value[2]);
            }

            // Load and init the module. We try a constructor with a port
            // if a port was given, fall back to one without if there is
            // no port or the more specific constructor fails.
            // This will be removed, so that any module capable of using a port
            // must provide a constructor with a port in the future.
            // For now, we do this so migration is easy.
            //
            foreach (TypeExtensionNode node in m_sharedModules)
            {
                Object[] ctorArgs = new Object[] { (uint)0 };

                // Read the config again
                string moduleString =
                        modulesConfig.GetString("Setup_" + node.Id, String.Empty);

                // Get the port number, if there is one
                if (moduleString != String.Empty)
                {
                    // Get the port number from the string
                    string[] moduleParts = moduleString.Split(new char[] { '/' },
                            2);
                    if (moduleParts.Length > 1)
                        ctorArgs[0] = Convert.ToUInt32(moduleParts[0]);
                }

                // Try loading and initilaizing the module, using the
                // port if appropriate
                ISharedRegionModule module = null;

                try
                {
                    module = (ISharedRegionModule)Activator.CreateInstance(
                            node.Type, ctorArgs);
                }
                catch
                {
                    module = (ISharedRegionModule)Activator.CreateInstance(
                            node.Type);
                }

                // OK, we're up and running
                m_sharedInstances.Add(module);
                module.Initialise(m_openSim.ConfigSource.Source);
            }
        }
示例#27
0
 public void Initialise(OpenSimBase openSim)
 {
     m_app = openSim;
     m_admin = new RemoteAdmin();
 }
示例#28
0
        //could move our main function into OpenSimMain and kill this class
        public static void Main(string[] args)
        {
            // First line, hook the appdomain to the crash reporter
            AppDomain.CurrentDomain.UnhandledException +=
                new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            // Add the arguments supplied when running the application to the configuration
            ArgvConfigSource configSource = new ArgvConfigSource(args);

            // Configure Log4Net
            configSource.AddSwitch("Startup", "logconfig");
            string logConfigFile = configSource.Configs["Startup"].GetString("logconfig", String.Empty);
            if (logConfigFile != String.Empty)
            {
                XmlConfigurator.Configure(new System.IO.FileInfo(logConfigFile));
                m_log.InfoFormat("[OPENSIM MAIN]: configured log4net using \"{0}\" as configuration file", 
                                 logConfigFile);
            } 
            else
            {
                XmlConfigurator.Configure();
                m_log.Info("[OPENSIM MAIN]: configured log4net using default OpenSim.exe.config");
            }

            // Increase the number of IOCP threads available. Mono defaults to a tragically low number
            int workerThreads, iocpThreads;
            System.Threading.ThreadPool.GetMaxThreads(out workerThreads, out iocpThreads);
            m_log.InfoFormat("[OPENSIM MAIN]: Runtime gave us {0} worker threads and {1} IOCP threads", workerThreads, iocpThreads);
            if (workerThreads < 500 || iocpThreads < 1000)
            {
                workerThreads = 500;
                iocpThreads = 1000;
                m_log.Info("[OPENSIM MAIN]: Bumping up to 500 worker threads and 1000 IOCP threads");
                System.Threading.ThreadPool.SetMaxThreads(workerThreads, iocpThreads);
            }

            // Check if the system is compatible with OpenSimulator.
            // Ensures that the minimum system requirements are met
            m_log.Info("Performing compatibility checks... \n");
            string supported = String.Empty;
            if (Util.IsEnvironmentSupported(ref supported))
            {
                m_log.Info("Environment is compatible.\n");
            }
            else
            {
                m_log.Warn("Environment is unsupported (" + supported + ")\n");
            }

            // Configure nIni aliases and localles
            Culture.SetCurrentCulture();


            // Validate that the user has the most basic configuration done
            // If not, offer to do the most basic configuration for them warning them along the way of the importance of 
            // reading these files.
            /*
            m_log.Info("Checking for reguired configuration...\n");

            bool OpenSim_Ini = (File.Exists(Path.Combine(Util.configDir(), "OpenSim.ini")))
                               || (File.Exists(Path.Combine(Util.configDir(), "opensim.ini")))
                               || (File.Exists(Path.Combine(Util.configDir(), "openSim.ini")))
                               || (File.Exists(Path.Combine(Util.configDir(), "Opensim.ini")));
            
            bool StanaloneCommon_ProperCased = File.Exists(Path.Combine(Path.Combine(Util.configDir(), "config-include"), "StandaloneCommon.ini"));
            bool StanaloneCommon_lowercased = File.Exists(Path.Combine(Path.Combine(Util.configDir(), "config-include"), "standalonecommon.ini"));
            bool GridCommon_ProperCased = File.Exists(Path.Combine(Path.Combine(Util.configDir(), "config-include"), "GridCommon.ini"));
            bool GridCommon_lowerCased = File.Exists(Path.Combine(Path.Combine(Util.configDir(), "config-include"), "gridcommon.ini"));

            if ((OpenSim_Ini) 
                && (
                (StanaloneCommon_ProperCased
                || StanaloneCommon_lowercased
                || GridCommon_ProperCased
                || GridCommon_lowerCased
                )))
            {
                m_log.Info("Required Configuration Files Found\n");
            }
            else
            {
                MainConsole.Instance = new LocalConsole("Region");
                string resp = MainConsole.Instance.CmdPrompt(
                                        "\n\n*************Required Configuration files not found.*************\n\n   OpenSimulator will not run without these files.\n\nRemember, these file names are Case Sensitive in Linux and Proper Cased.\n1. ./OpenSim.ini\nand\n2. ./config-include/StandaloneCommon.ini \nor\n3. ./config-include/GridCommon.ini\n\nAlso, you will want to examine these files in great detail because only the basic system will load by default. OpenSimulator can do a LOT more if you spend a little time going through these files.\n\n" + ": " + "Do you want to copy the most basic Defaults from standalone?",
                                        "yes");
                if (resp == "yes")
                {
                    
                        if (!(OpenSim_Ini))
                        {
                            try
                            {
                                File.Copy(Path.Combine(Util.configDir(), "OpenSim.ini.example"),
                                          Path.Combine(Util.configDir(), "OpenSim.ini"));
                            } catch (UnauthorizedAccessException)
                            {
                                MainConsole.Instance.Output("Unable to Copy OpenSim.ini.example to OpenSim.ini, Make sure OpenSim has have the required permissions\n");
                            } catch (ArgumentException)
                            {
                                MainConsole.Instance.Output("Unable to Copy OpenSim.ini.example to OpenSim.ini, The current directory is invalid.\n");
                            } catch (System.IO.PathTooLongException)
                            {
                                MainConsole.Instance.Output("Unable to Copy OpenSim.ini.example to OpenSim.ini, the Path to these files is too long.\n");
                            } catch (System.IO.DirectoryNotFoundException)
                            {
                                MainConsole.Instance.Output("Unable to Copy OpenSim.ini.example to OpenSim.ini, the current directory is reporting as not found.\n");
                            } catch (System.IO.FileNotFoundException)
                            {
                                MainConsole.Instance.Output("Unable to Copy OpenSim.ini.example to OpenSim.ini, the example is not found, please make sure that the example files exist.\n");
                            } catch (System.IO.IOException)
                            {
                                // Destination file exists already or a hard drive failure...   ..    so we can just drop this one
                                //MainConsole.Instance.Output("Unable to Copy OpenSim.ini.example to OpenSim.ini, the example is not found, please make sure that the example files exist.\n");
                            } catch (System.NotSupportedException)
                            {
                                MainConsole.Instance.Output("Unable to Copy OpenSim.ini.example to OpenSim.ini, The current directory is invalid.\n");
                            }

                        }
                        if (!(StanaloneCommon_ProperCased || StanaloneCommon_lowercased))
                        {
                            try
                            {
                                File.Copy(Path.Combine(Path.Combine(Util.configDir(), "config-include"), "StandaloneCommon.ini.example"),
                                          Path.Combine(Path.Combine(Util.configDir(), "config-include"), "StandaloneCommon.ini"));
                            }
                            catch (UnauthorizedAccessException)
                            {
                                MainConsole.Instance.Output("Unable to Copy StandaloneCommon.ini.example to StandaloneCommon.ini, Make sure OpenSim has the required permissions\n");
                            }
                            catch (ArgumentException)
                            {
                                MainConsole.Instance.Output("Unable to Copy StandaloneCommon.ini.example to StandaloneCommon.ini, The current directory is invalid.\n");
                            }
                            catch (System.IO.PathTooLongException)
                            {
                                MainConsole.Instance.Output("Unable to Copy StandaloneCommon.ini.example to StandaloneCommon.ini, the Path to these files is too long.\n");
                            }
                            catch (System.IO.DirectoryNotFoundException)
                            {
                                MainConsole.Instance.Output("Unable to Copy StandaloneCommon.ini.example to StandaloneCommon.ini, the current directory is reporting as not found.\n");
                            }
                            catch (System.IO.FileNotFoundException)
                            {
                                MainConsole.Instance.Output("Unable to Copy StandaloneCommon.ini.example to StandaloneCommon.ini, the example is not found, please make sure that the example files exist.\n");
                            }
                            catch (System.IO.IOException)
                            {
                                // Destination file exists already or a hard drive failure...   ..    so we can just drop this one
                                //MainConsole.Instance.Output("Unable to Copy OpenSim.ini.example to OpenSim.ini, the example is not found, please make sure that the example files exist.\n");
                            }
                            catch (System.NotSupportedException)
                            {
                                MainConsole.Instance.Output("Unable to Copy StandaloneCommon.ini.example to StandaloneCommon.ini, The current directory is invalid.\n");
                            }
                        }
                }
                MainConsole.Instance = null;
            }      
            */
            configSource.Alias.AddAlias("On", true);
            configSource.Alias.AddAlias("Off", false);
            configSource.Alias.AddAlias("True", true);
            configSource.Alias.AddAlias("False", false);

            configSource.AddSwitch("Startup", "background");
            configSource.AddSwitch("Startup", "inifile");
            configSource.AddSwitch("Startup", "inimaster");
            configSource.AddSwitch("Startup", "inidirectory");
            configSource.AddSwitch("Startup", "physics");
            configSource.AddSwitch("Startup", "gui");
            configSource.AddSwitch("Startup", "console");

            configSource.AddConfig("StandAlone");
            configSource.AddConfig("Network");

            // Check if we're running in the background or not
            bool background = configSource.Configs["Startup"].GetBoolean("background", false);

            // Check if we're saving crashes
            m_saveCrashDumps = configSource.Configs["Startup"].GetBoolean("save_crashes", false);

            // load Crash directory config
            m_crashDir = configSource.Configs["Startup"].GetString("crash_dir", m_crashDir);

           

            if (background)
            {
                m_sim = new OpenSimBackground(configSource);
                m_sim.Startup();
            }
            else
            {


                       

                m_sim = new OpenSim(configSource);

                    
      
                m_sim.Startup();

                while (true)
                {
                    try
                    {
                        // Block thread here for input
                        MainConsole.Instance.Prompt();
                    }
                    catch (Exception e)
                    {
                        m_log.ErrorFormat("Command error: {0}", e);
                    }
                }
            }
        }
示例#29
0
        //could move our main function into OpenSimMain and kill this class
        public static void Main(string[] args)
        {
            // First line, hook the appdomain to the crash reporter
            AppDomain.CurrentDomain.UnhandledException +=
                new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            ServicePointManager.DefaultConnectionLimit = 12;

            // Add the arguments supplied when running the application to the configuration
            ArgvConfigSource configSource = new ArgvConfigSource(args);

            // Configure Log4Net
            configSource.AddSwitch("Startup", "logconfig");
            string logConfigFile = configSource.Configs["Startup"].GetString("logconfig", String.Empty);
            if (logConfigFile != String.Empty)
            {
                XmlConfigurator.Configure(new System.IO.FileInfo(logConfigFile));
                m_log.InfoFormat("[OPENSIM MAIN]: configured log4net using \"{0}\" as configuration file", 
                                 logConfigFile);
            } 
            else
            {
                XmlConfigurator.Configure();
                m_log.Info("[OPENSIM MAIN]: configured log4net using default OpenSim.exe.config");
            }

            m_log.InfoFormat(
                "[OPENSIM MAIN]: System Locale is {0}", System.Threading.Thread.CurrentThread.CurrentCulture);

            string monoThreadsPerCpu = System.Environment.GetEnvironmentVariable("MONO_THREADS_PER_CPU");

            m_log.InfoFormat(
                "[OPENSIM MAIN]: Environment variable MONO_THREADS_PER_CPU is {0}", monoThreadsPerCpu ?? "unset");

            // Verify the Threadpool allocates or uses enough worker and IO completion threads
			// .NET 2.0, workerthreads default to 50 *  numcores
			// .NET 3.0, workerthreads defaults to 250 * numcores
			// .NET 4.0, workerthreads are dynamic based on bitness and OS resources
            // Max IO Completion threads are 1000 on all 3 CLRs
            //
            // Mono 2.10.9 to at least Mono 3.1, workerthreads default to 100 * numcores, iocp threads to 4 * numcores
			int workerThreadsMin = 500;
			int workerThreadsMax = 1000; // may need further adjustment to match other CLR
			int iocpThreadsMin = 1000;
			int iocpThreadsMax = 2000; // may need further adjustment to match other CLR

            {
                int currentMinWorkerThreads, currentMinIocpThreads;
                System.Threading.ThreadPool.GetMinThreads(out currentMinWorkerThreads, out currentMinIocpThreads);
                m_log.InfoFormat(
                    "[OPENSIM MAIN]: Runtime gave us {0} min worker threads and {1} min IOCP threads", 
                    currentMinWorkerThreads, currentMinIocpThreads);
            }

            int workerThreads, iocpThreads;
            System.Threading.ThreadPool.GetMaxThreads(out workerThreads, out iocpThreads);
            m_log.InfoFormat("[OPENSIM MAIN]: Runtime gave us {0} max worker threads and {1} max IOCP threads", workerThreads, iocpThreads);

            if (workerThreads < workerThreadsMin)
            {
                workerThreads = workerThreadsMin;
                m_log.InfoFormat("[OPENSIM MAIN]: Bumping up max worker threads to {0}",workerThreads);
            }
            if (workerThreads > workerThreadsMax)
            {
                workerThreads = workerThreadsMax;
                m_log.InfoFormat("[OPENSIM MAIN]: Limiting max worker threads to {0}",workerThreads);
            }

			// Increase the number of IOCP threads available.
			// Mono defaults to a tragically low number (24 on 6-core / 8GB Fedora 17)
			if (iocpThreads < iocpThreadsMin)
            {
                iocpThreads = iocpThreadsMin;
                m_log.InfoFormat("[OPENSIM MAIN]: Bumping up max IOCP threads to {0}",iocpThreads);
            }
			// Make sure we don't overallocate IOCP threads and thrash system resources
            if ( iocpThreads > iocpThreadsMax )
            {
                iocpThreads = iocpThreadsMax;
                m_log.InfoFormat("[OPENSIM MAIN]: Limiting max IOCP completion threads to {0}",iocpThreads);
            }
			// set the resulting worker and IO completion thread counts back to ThreadPool
            if ( System.Threading.ThreadPool.SetMaxThreads(workerThreads, iocpThreads) )
			{
	            m_log.InfoFormat(
                    "[OPENSIM MAIN]: Threadpool set to {0} max worker threads and {1} max IOCP threads",
                    workerThreads, iocpThreads);
			}
			else
			{
	            m_log.Warn("[OPENSIM MAIN]: Threadpool reconfiguration failed, runtime defaults still in effect.");				
			}

            // Check if the system is compatible with OpenSimulator.
            // Ensures that the minimum system requirements are met
            string supported = String.Empty;
            if (Util.IsEnvironmentSupported(ref supported))
            {
                m_log.Info("[OPENSIM MAIN]: Environment is supported by OpenSimulator.");
            }
            else
            {
                m_log.Warn("[OPENSIM MAIN]: Environment is not supported by OpenSimulator (" + supported + ")\n");
            }

            // Configure nIni aliases and localles
            Culture.SetCurrentCulture();

            // Validate that the user has the most basic configuration done
            // If not, offer to do the most basic configuration for them warning them along the way of the importance of 
            // reading these files.
            /*
            m_log.Info("Checking for reguired configuration...\n");

            bool OpenSim_Ini = (File.Exists(Path.Combine(Util.configDir(), "OpenSim.ini")))
                               || (File.Exists(Path.Combine(Util.configDir(), "opensim.ini")))
                               || (File.Exists(Path.Combine(Util.configDir(), "openSim.ini")))
                               || (File.Exists(Path.Combine(Util.configDir(), "Opensim.ini")));
            
            bool StanaloneCommon_ProperCased = File.Exists(Path.Combine(Path.Combine(Util.configDir(), "config-include"), "StandaloneCommon.ini"));
            bool StanaloneCommon_lowercased = File.Exists(Path.Combine(Path.Combine(Util.configDir(), "config-include"), "standalonecommon.ini"));
            bool GridCommon_ProperCased = File.Exists(Path.Combine(Path.Combine(Util.configDir(), "config-include"), "GridCommon.ini"));
            bool GridCommon_lowerCased = File.Exists(Path.Combine(Path.Combine(Util.configDir(), "config-include"), "gridcommon.ini"));

            if ((OpenSim_Ini) 
                && (
                (StanaloneCommon_ProperCased
                || StanaloneCommon_lowercased
                || GridCommon_ProperCased
                || GridCommon_lowerCased
                )))
            {
                m_log.Info("Required Configuration Files Found\n");
            }
            else
            {
                MainConsole.Instance = new LocalConsole("Region");
                string resp = MainConsole.Instance.CmdPrompt(
                                        "\n\n*************Required Configuration files not found.*************\n\n   OpenSimulator will not run without these files.\n\nRemember, these file names are Case Sensitive in Linux and Proper Cased.\n1. ./OpenSim.ini\nand\n2. ./config-include/StandaloneCommon.ini \nor\n3. ./config-include/GridCommon.ini\n\nAlso, you will want to examine these files in great detail because only the basic system will load by default. OpenSimulator can do a LOT more if you spend a little time going through these files.\n\n" + ": " + "Do you want to copy the most basic Defaults from standalone?",
                                        "yes");
                if (resp == "yes")
                {
                    
                        if (!(OpenSim_Ini))
                        {
                            try
                            {
                                File.Copy(Path.Combine(Util.configDir(), "OpenSim.ini.example"),
                                          Path.Combine(Util.configDir(), "OpenSim.ini"));
                            } catch (UnauthorizedAccessException)
                            {
                                MainConsole.Instance.Output("Unable to Copy OpenSim.ini.example to OpenSim.ini, Make sure OpenSim has have the required permissions\n");
                            } catch (ArgumentException)
                            {
                                MainConsole.Instance.Output("Unable to Copy OpenSim.ini.example to OpenSim.ini, The current directory is invalid.\n");
                            } catch (System.IO.PathTooLongException)
                            {
                                MainConsole.Instance.Output("Unable to Copy OpenSim.ini.example to OpenSim.ini, the Path to these files is too long.\n");
                            } catch (System.IO.DirectoryNotFoundException)
                            {
                                MainConsole.Instance.Output("Unable to Copy OpenSim.ini.example to OpenSim.ini, the current directory is reporting as not found.\n");
                            } catch (System.IO.FileNotFoundException)
                            {
                                MainConsole.Instance.Output("Unable to Copy OpenSim.ini.example to OpenSim.ini, the example is not found, please make sure that the example files exist.\n");
                            } catch (System.IO.IOException)
                            {
                                // Destination file exists already or a hard drive failure...   ..    so we can just drop this one
                                //MainConsole.Instance.Output("Unable to Copy OpenSim.ini.example to OpenSim.ini, the example is not found, please make sure that the example files exist.\n");
                            } catch (System.NotSupportedException)
                            {
                                MainConsole.Instance.Output("Unable to Copy OpenSim.ini.example to OpenSim.ini, The current directory is invalid.\n");
                            }

                        }
                        if (!(StanaloneCommon_ProperCased || StanaloneCommon_lowercased))
                        {
                            try
                            {
                                File.Copy(Path.Combine(Path.Combine(Util.configDir(), "config-include"), "StandaloneCommon.ini.example"),
                                          Path.Combine(Path.Combine(Util.configDir(), "config-include"), "StandaloneCommon.ini"));
                            }
                            catch (UnauthorizedAccessException)
                            {
                                MainConsole.Instance.Output("Unable to Copy StandaloneCommon.ini.example to StandaloneCommon.ini, Make sure OpenSim has the required permissions\n");
                            }
                            catch (ArgumentException)
                            {
                                MainConsole.Instance.Output("Unable to Copy StandaloneCommon.ini.example to StandaloneCommon.ini, The current directory is invalid.\n");
                            }
                            catch (System.IO.PathTooLongException)
                            {
                                MainConsole.Instance.Output("Unable to Copy StandaloneCommon.ini.example to StandaloneCommon.ini, the Path to these files is too long.\n");
                            }
                            catch (System.IO.DirectoryNotFoundException)
                            {
                                MainConsole.Instance.Output("Unable to Copy StandaloneCommon.ini.example to StandaloneCommon.ini, the current directory is reporting as not found.\n");
                            }
                            catch (System.IO.FileNotFoundException)
                            {
                                MainConsole.Instance.Output("Unable to Copy StandaloneCommon.ini.example to StandaloneCommon.ini, the example is not found, please make sure that the example files exist.\n");
                            }
                            catch (System.IO.IOException)
                            {
                                // Destination file exists already or a hard drive failure...   ..    so we can just drop this one
                                //MainConsole.Instance.Output("Unable to Copy OpenSim.ini.example to OpenSim.ini, the example is not found, please make sure that the example files exist.\n");
                            }
                            catch (System.NotSupportedException)
                            {
                                MainConsole.Instance.Output("Unable to Copy StandaloneCommon.ini.example to StandaloneCommon.ini, The current directory is invalid.\n");
                            }
                        }
                }
                MainConsole.Instance = null;
            }
            */
            configSource.Alias.AddAlias("On", true);
            configSource.Alias.AddAlias("Off", false);
            configSource.Alias.AddAlias("True", true);
            configSource.Alias.AddAlias("False", false);
            configSource.Alias.AddAlias("Yes", true);
            configSource.Alias.AddAlias("No", false);

            configSource.AddSwitch("Startup", "background");
            configSource.AddSwitch("Startup", "inifile");
            configSource.AddSwitch("Startup", "inimaster");
            configSource.AddSwitch("Startup", "inidirectory");
            configSource.AddSwitch("Startup", "physics");
            configSource.AddSwitch("Startup", "gui");
            configSource.AddSwitch("Startup", "console");
            configSource.AddSwitch("Startup", "save_crashes");
            configSource.AddSwitch("Startup", "crash_dir");

            configSource.AddConfig("StandAlone");
            configSource.AddConfig("Network");

            // Check if we're running in the background or not
            bool background = configSource.Configs["Startup"].GetBoolean("background", false);

            // Check if we're saving crashes
            m_saveCrashDumps = configSource.Configs["Startup"].GetBoolean("save_crashes", false);

            // load Crash directory config
            m_crashDir = configSource.Configs["Startup"].GetString("crash_dir", m_crashDir);           

            if (background)
            {
                m_sim = new OpenSimBackground(configSource);
                m_sim.Startup();
            }
            else
            {                       
                m_sim = new OpenSim(configSource);
                          
                m_sim.Startup();

                while (true)
                {
                    try
                    {
                        // Block thread here for input
                        MainConsole.Instance.Prompt();
                    }
                    catch (Exception e)
                    {
                        m_log.ErrorFormat("Command error: {0}", e);
                    }
                }
            }
        }
示例#30
0
 public void Initialise(OpenSimBase openSim)
 {
 }
示例#31
0
 public XSimStatusHandler(OpenSimBase sim)
 {
     m_opensim = sim;
     osXStatsURI = Util.SHA1Hash(sim.osSecret);
 }
 public void Initialise(OpenSimBase sim) 
 {
     m_openSim = sim;
 }
示例#33
0
        //could move our main function into OpenSimMain and kill this class
        public static void Main(string[] args)
        {
            // First line, hook the appdomain to the crash reporter
            AppDomain.CurrentDomain.UnhandledException +=
                new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            Culture.SetCurrentCulture();
            Culture.SetDefaultCurrentCulture();

            if (Util.IsWindows())
            {
                ServicePointManager.DefaultConnectionLimit = 32;
            }
            else
            {
                ServicePointManager.DefaultConnectionLimit = 12;
            }

            try { ServicePointManager.DnsRefreshTimeout = 300000; } catch { }
            ServicePointManager.Expect100Continue = false;
            ServicePointManager.UseNagleAlgorithm = false;

            // Add the arguments supplied when running the application to the configuration
            ArgvConfigSource configSource = new ArgvConfigSource(args);

            // Configure Log4Net
            configSource.AddSwitch("Startup", "logconfig");
            string logConfigFile = configSource.Configs["Startup"].GetString("logconfig", String.Empty);

            if (logConfigFile != String.Empty)
            {
                XmlConfigurator.Configure(new System.IO.FileInfo(logConfigFile));
                m_log.InfoFormat("[OPENSIM MAIN]: configured log4net using \"{0}\" as configuration file",
                                 logConfigFile);
            }
            else
            {
                XmlConfigurator.Configure();
                m_log.Info("[OPENSIM MAIN]: configured log4net using default OpenSim.exe.config");
            }

            m_log.InfoFormat(
                "[OPENSIM MAIN]: System Locale is {0}", System.Threading.Thread.CurrentThread.CurrentCulture);

            string monoThreadsPerCpu = System.Environment.GetEnvironmentVariable("MONO_THREADS_PER_CPU");

            m_log.InfoFormat(
                "[OPENSIM MAIN]: Environment variable MONO_THREADS_PER_CPU is {0}", monoThreadsPerCpu ?? "unset");

            // Verify the Threadpool allocates or uses enough worker and IO completion threads
            // .NET 2.0, workerthreads default to 50 *  numcores
            // .NET 3.0, workerthreads defaults to 250 * numcores
            // .NET 4.0, workerthreads are dynamic based on bitness and OS resources
            // Max IO Completion threads are 1000 on all 3 CLRs
            //
            // Mono 2.10.9 to at least Mono 3.1, workerthreads default to 100 * numcores, iocp threads to 4 * numcores
            int workerThreadsMin = 500;
            int workerThreadsMax = 1000; // may need further adjustment to match other CLR
            int iocpThreadsMin   = 1000;
            int iocpThreadsMax   = 2000; // may need further adjustment to match other CLR

            {
                int currentMinWorkerThreads, currentMinIocpThreads;
                System.Threading.ThreadPool.GetMinThreads(out currentMinWorkerThreads, out currentMinIocpThreads);
                m_log.InfoFormat(
                    "[OPENSIM MAIN]: Runtime gave us {0} min worker threads and {1} min IOCP threads",
                    currentMinWorkerThreads, currentMinIocpThreads);
            }

            int workerThreads, iocpThreads;

            System.Threading.ThreadPool.GetMaxThreads(out workerThreads, out iocpThreads);
            m_log.InfoFormat("[OPENSIM MAIN]: Runtime gave us {0} max worker threads and {1} max IOCP threads", workerThreads, iocpThreads);

            if (workerThreads < workerThreadsMin)
            {
                workerThreads = workerThreadsMin;
                m_log.InfoFormat("[OPENSIM MAIN]: Bumping up max worker threads to {0}", workerThreads);
            }
            if (workerThreads > workerThreadsMax)
            {
                workerThreads = workerThreadsMax;
                m_log.InfoFormat("[OPENSIM MAIN]: Limiting max worker threads to {0}", workerThreads);
            }

            // Increase the number of IOCP threads available.
            // Mono defaults to a tragically low number (24 on 6-core / 8GB Fedora 17)
            if (iocpThreads < iocpThreadsMin)
            {
                iocpThreads = iocpThreadsMin;
                m_log.InfoFormat("[OPENSIM MAIN]: Bumping up max IOCP threads to {0}", iocpThreads);
            }
            // Make sure we don't overallocate IOCP threads and thrash system resources
            if (iocpThreads > iocpThreadsMax)
            {
                iocpThreads = iocpThreadsMax;
                m_log.InfoFormat("[OPENSIM MAIN]: Limiting max IOCP completion threads to {0}", iocpThreads);
            }
            // set the resulting worker and IO completion thread counts back to ThreadPool
            if (System.Threading.ThreadPool.SetMaxThreads(workerThreads, iocpThreads))
            {
                m_log.InfoFormat(
                    "[OPENSIM MAIN]: Threadpool set to {0} max worker threads and {1} max IOCP threads",
                    workerThreads, iocpThreads);
            }
            else
            {
                m_log.Warn("[OPENSIM MAIN]: Threadpool reconfiguration failed, runtime defaults still in effect.");
            }

            // Check if the system is compatible with OpenSimulator.
            // Ensures that the minimum system requirements are met
            string supported = String.Empty;

            if (Util.IsEnvironmentSupported(ref supported))
            {
                m_log.Info("[OPENSIM MAIN]: Environment is supported by OpenSimulator.");
            }
            else
            {
                m_log.Warn("[OPENSIM MAIN]: Environment is not supported by OpenSimulator (" + supported + ")\n");
            }

            m_log.InfoFormat("Default culture changed to {0}", Culture.GetDefaultCurrentCulture().DisplayName);

            // Configure nIni aliases and localles

            // Validate that the user has the most basic configuration done
            // If not, offer to do the most basic configuration for them warning them along the way of the importance of
            // reading these files.

            /*
             * m_log.Info("Checking for reguired configuration...\n");
             *
             * bool OpenSim_Ini = (File.Exists(Path.Combine(Util.configDir(), "OpenSim.ini")))
             || (File.Exists(Path.Combine(Util.configDir(), "opensim.ini")))
             || (File.Exists(Path.Combine(Util.configDir(), "openSim.ini")))
             || (File.Exists(Path.Combine(Util.configDir(), "Opensim.ini")));
             ||
             ||bool StanaloneCommon_ProperCased = File.Exists(Path.Combine(Path.Combine(Util.configDir(), "config-include"), "StandaloneCommon.ini"));
             ||bool StanaloneCommon_lowercased = File.Exists(Path.Combine(Path.Combine(Util.configDir(), "config-include"), "standalonecommon.ini"));
             ||bool GridCommon_ProperCased = File.Exists(Path.Combine(Path.Combine(Util.configDir(), "config-include"), "GridCommon.ini"));
             ||bool GridCommon_lowerCased = File.Exists(Path.Combine(Path.Combine(Util.configDir(), "config-include"), "gridcommon.ini"));
             ||
             ||if ((OpenSim_Ini)
             || && (
             || (StanaloneCommon_ProperCased
             || StanaloneCommon_lowercased
             || GridCommon_ProperCased
             || GridCommon_lowerCased
             || )))
             ||{
             || m_log.Info("Required Configuration Files Found\n");
             ||}
             ||else
             ||{
             || MainConsole.Instance = new LocalConsole("Region");
             || string resp = MainConsole.Instance.CmdPrompt(
             ||                         "\n\n*************Required Configuration files not found.*************\n\n   OpenSimulator will not run without these files.\n\nRemember, these file names are Case Sensitive in Linux and Proper Cased.\n1. ./OpenSim.ini\nand\n2. ./config-include/StandaloneCommon.ini \nor\n3. ./config-include/GridCommon.ini\n\nAlso, you will want to examine these files in great detail because only the basic system will load by default. OpenSimulator can do a LOT more if you spend a little time going through these files.\n\n" + ": " + "Do you want to copy the most basic Defaults from standalone?",
             ||                         "yes");
             || if (resp == "yes")
             || {
             ||
             ||         if (!(OpenSim_Ini))
             ||         {
             ||             try
             ||             {
             ||                 File.Copy(Path.Combine(Util.configDir(), "OpenSim.ini.example"),
             ||                           Path.Combine(Util.configDir(), "OpenSim.ini"));
             ||             } catch (UnauthorizedAccessException)
             ||             {
             ||                 MainConsole.Instance.Output("Unable to Copy OpenSim.ini.example to OpenSim.ini, Make sure OpenSim has have the required permissions\n");
             ||             } catch (ArgumentException)
             ||             {
             ||                 MainConsole.Instance.Output("Unable to Copy OpenSim.ini.example to OpenSim.ini, The current directory is invalid.\n");
             ||             } catch (System.IO.PathTooLongException)
             ||             {
             ||                 MainConsole.Instance.Output("Unable to Copy OpenSim.ini.example to OpenSim.ini, the Path to these files is too long.\n");
             ||             } catch (System.IO.DirectoryNotFoundException)
             ||             {
             ||                 MainConsole.Instance.Output("Unable to Copy OpenSim.ini.example to OpenSim.ini, the current directory is reporting as not found.\n");
             ||             } catch (System.IO.FileNotFoundException)
             ||             {
             ||                 MainConsole.Instance.Output("Unable to Copy OpenSim.ini.example to OpenSim.ini, the example is not found, please make sure that the example files exist.\n");
             ||             } catch (System.IO.IOException)
             ||             {
             ||                 // Destination file exists already or a hard drive failure...   ..    so we can just drop this one
             ||                 //MainConsole.Instance.Output("Unable to Copy OpenSim.ini.example to OpenSim.ini, the example is not found, please make sure that the example files exist.\n");
             ||             } catch (System.NotSupportedException)
             ||             {
             ||                 MainConsole.Instance.Output("Unable to Copy OpenSim.ini.example to OpenSim.ini, The current directory is invalid.\n");
             ||             }
             ||
             ||         }
             ||         if (!(StanaloneCommon_ProperCased || StanaloneCommon_lowercased))
             ||         {
             ||             try
             ||             {
             ||                 File.Copy(Path.Combine(Path.Combine(Util.configDir(), "config-include"), "StandaloneCommon.ini.example"),
             ||                           Path.Combine(Path.Combine(Util.configDir(), "config-include"), "StandaloneCommon.ini"));
             ||             }
             ||             catch (UnauthorizedAccessException)
             ||             {
             ||                 MainConsole.Instance.Output("Unable to Copy StandaloneCommon.ini.example to StandaloneCommon.ini, Make sure OpenSim has the required permissions\n");
             ||             }
             ||             catch (ArgumentException)
             ||             {
             ||                 MainConsole.Instance.Output("Unable to Copy StandaloneCommon.ini.example to StandaloneCommon.ini, The current directory is invalid.\n");
             ||             }
             ||             catch (System.IO.PathTooLongException)
             ||             {
             ||                 MainConsole.Instance.Output("Unable to Copy StandaloneCommon.ini.example to StandaloneCommon.ini, the Path to these files is too long.\n");
             ||             }
             ||             catch (System.IO.DirectoryNotFoundException)
             ||             {
             ||                 MainConsole.Instance.Output("Unable to Copy StandaloneCommon.ini.example to StandaloneCommon.ini, the current directory is reporting as not found.\n");
             ||             }
             ||             catch (System.IO.FileNotFoundException)
             ||             {
             ||                 MainConsole.Instance.Output("Unable to Copy StandaloneCommon.ini.example to StandaloneCommon.ini, the example is not found, please make sure that the example files exist.\n");
             ||             }
             ||             catch (System.IO.IOException)
             ||             {
             ||                 // Destination file exists already or a hard drive failure...   ..    so we can just drop this one
             ||                 //MainConsole.Instance.Output("Unable to Copy OpenSim.ini.example to OpenSim.ini, the example is not found, please make sure that the example files exist.\n");
             ||             }
             ||             catch (System.NotSupportedException)
             ||             {
             ||                 MainConsole.Instance.Output("Unable to Copy StandaloneCommon.ini.example to StandaloneCommon.ini, The current directory is invalid.\n");
             ||             }
             ||         }
             || }
             || MainConsole.Instance = null;
             ||}
             */
            configSource.Alias.AddAlias("On", true);
            configSource.Alias.AddAlias("Off", false);
            configSource.Alias.AddAlias("True", true);
            configSource.Alias.AddAlias("False", false);
            configSource.Alias.AddAlias("Yes", true);
            configSource.Alias.AddAlias("No", false);

            configSource.AddSwitch("Startup", "background");
            configSource.AddSwitch("Startup", "inifile");
            configSource.AddSwitch("Startup", "inimaster");
            configSource.AddSwitch("Startup", "inidirectory");
            configSource.AddSwitch("Startup", "physics");
            configSource.AddSwitch("Startup", "gui");
            configSource.AddSwitch("Startup", "console");
            configSource.AddSwitch("Startup", "save_crashes");
            configSource.AddSwitch("Startup", "crash_dir");

            configSource.AddConfig("StandAlone");
            configSource.AddConfig("Network");

            // Check if we're running in the background or not
            bool background = configSource.Configs["Startup"].GetBoolean("background", false);

            // Check if we're saving crashes
            m_saveCrashDumps = configSource.Configs["Startup"].GetBoolean("save_crashes", false);

            // load Crash directory config
            m_crashDir = configSource.Configs["Startup"].GetString("crash_dir", m_crashDir);

            if (background)
            {
                m_sim = new OpenSimBackground(configSource);
                m_sim.Startup();
            }
            else
            {
                m_sim = new OpenSim(configSource);

                m_sim.Startup();

                while (true)
                {
                    try
                    {
                        // Block thread here for input
                        MainConsole.Instance.Prompt();
                    }
                    catch (Exception e)
                    {
                        m_log.ErrorFormat("Command error: {0}", e);
                    }
                }
            }
        }
示例#34
0
 public void Initialize(IOpenSimBase openSim)
 {
     m_openSim = (OpenSimBase)openSim;
     MainConsole.Instance.Commands.AddCommand("base", false, "open region manager", "open region manager", "Opens the region manager", OpenRegionManager);
     m_openSim.ApplicationRegistry.RegisterInterface<IRegionCreator>(this);
 }
示例#35
0
 public UXSimStatusHandler(OpenSimBase sim)
     : base("GET", "/" + sim.userStatsURI, "UXSimStatus", "Simulator UXStatus")
 {
     m_opensim = sim;                
 }
示例#36
0
        public static void Startup(ArgvConfigSource configSource)
        {
            OpenSimBase m_sim = new OpenSimBase(configSource);
            try
            {
                m_sim.Startup();
            }
            catch (Exception ex)
            {
                if (ex.Message != "Restart") //Internal needs a restart message
                {
                    string mes = "[AURORA]: Aurora has crashed! Error: " + ex + ", Stack trace: " + ex.StackTrace;

                    m_log.Error(mes);
                    handleException(mes, ex);
                }
                //Just clean it out as good as we can
                m_sim.Shutdown(false);
                //Then let it restart if it needs
                return;
            }
            Environment.Exit(0);
        }
示例#37
0
        public void Initialise(OpenSimBase openSim)
        {
            m_configSource = openSim.ConfigSource.Source;
            try
            {
                if (m_configSource.Configs["RemoteAdmin"] == null ||
                    !m_configSource.Configs["RemoteAdmin"].GetBoolean("enabled", false))
                {
                    // No config or disabled
                }
                else
                {
                    m_config = m_configSource.Configs["RemoteAdmin"];
                    m_log.Debug("[RADMIN]: Remote Admin Plugin Enabled");
                    m_requiredPassword = m_config.GetString("access_password", String.Empty);
                    int port = m_config.GetInt("port", 0);

                    m_application = openSim;
                    string bind_ip_address = m_config.GetString("bind_ip_address", "0.0.0.0");
                    IPAddress ipaddr = IPAddress.Parse(bind_ip_address);
                    m_httpServer = MainServer.GetHttpServer((uint)port,ipaddr);

                    Dictionary<string, XmlRpcMethod> availableMethods = new Dictionary<string, XmlRpcMethod>();
                    availableMethods["admin_create_region"] = XmlRpcCreateRegionMethod;
                    availableMethods["admin_delete_region"] = XmlRpcDeleteRegionMethod;
                    availableMethods["admin_close_region"] = XmlRpcCloseRegionMethod;
                    availableMethods["admin_modify_region"] = XmlRpcModifyRegionMethod;
                    availableMethods["admin_region_query"] = XmlRpcRegionQueryMethod;
                    availableMethods["admin_shutdown"] = XmlRpcShutdownMethod;
                    availableMethods["admin_broadcast"] = XmlRpcAlertMethod;
                    availableMethods["admin_restart"] = XmlRpcRestartMethod;
                    availableMethods["admin_load_heightmap"] = XmlRpcLoadHeightmapMethod;
                    availableMethods["admin_save_heightmap"] = XmlRpcSaveHeightmapMethod;
                    // User management
                    availableMethods["admin_create_user"] = XmlRpcCreateUserMethod;
                    availableMethods["admin_create_user_email"] = XmlRpcCreateUserMethod;
                    availableMethods["admin_exists_user"] = XmlRpcUserExistsMethod;
                    availableMethods["admin_update_user"] = XmlRpcUpdateUserAccountMethod;
                    // Region state management
                    availableMethods["admin_load_xml"] = XmlRpcLoadXMLMethod;
                    availableMethods["admin_save_xml"] = XmlRpcSaveXMLMethod;
                    availableMethods["admin_load_oar"] = XmlRpcLoadOARMethod;
                    availableMethods["admin_save_oar"] = XmlRpcSaveOARMethod;
                    // Estate access list management
                    availableMethods["admin_acl_clear"] = XmlRpcAccessListClear;
                    availableMethods["admin_acl_add"] = XmlRpcAccessListAdd;
                    availableMethods["admin_acl_remove"] = XmlRpcAccessListRemove;
                    availableMethods["admin_acl_list"] = XmlRpcAccessListList;

                    // Either enable full remote functionality or just selected features
                    string enabledMethods = m_config.GetString("enabled_methods", "all");

                    // To get this, you must explicitly specify "all" or
                    // mention it in a whitelist. It won't be available
                    // If you just leave the option out!
                    //
                    if (!String.IsNullOrEmpty(enabledMethods))
                        availableMethods["admin_console_command"] = XmlRpcConsoleCommandMethod;

                    // The assumption here is that simply enabling Remote Admin as before will produce the same
                    // behavior - enable all methods unless the whitelist is in place for backward-compatibility.
                    if (enabledMethods.ToLower() == "all" || String.IsNullOrEmpty(enabledMethods))
                    {
                        foreach (string method in availableMethods.Keys)
                        {
                            m_httpServer.AddXmlRPCHandler(method, availableMethods[method], false);
                        }
                    }
                    else
                    {
                        foreach (string enabledMethod in enabledMethods.Split('|'))
                        {
                            m_httpServer.AddXmlRPCHandler(enabledMethod, availableMethods[enabledMethod]);
                        }
                    }
                }
            }
            catch (NullReferenceException)
            {
                // Ignore.
            }
        }
示例#38
0
        //could move our main function into OpenSimMain and kill this class
        public static void Main(string[] args)
        {
            // First line
            AppDomain.CurrentDomain.UnhandledException +=
                new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            ArgvConfigSource configSource = new ArgvConfigSource(args);
            configSource.AddSwitch("Startup", "logconfig");
            string logConfigFile = configSource.Configs["Startup"].GetString("logconfig", String.Empty);
            if (logConfigFile != String.Empty)
            {
                XmlConfigurator.Configure(new System.IO.FileInfo(logConfigFile));
                m_log.InfoFormat("[OPENSIM MAIN]: configured log4net using \"{0}\" as configuration file", 
                                 logConfigFile);
            } 
            else
            {
                XmlConfigurator.Configure();
                m_log.Info("[OPENSIM MAIN]: configured log4net using default OpenSim.exe.config");
            }

            m_log.Info("Performing compatibility checks... ");
            string supported = String.Empty;
            if (Util.IsEnvironmentSupported(ref supported))
            {
                m_log.Info("Environment is compatible.\n");
            }
            else
            {
                m_log.Warn("Environment is unsupported (" + supported + ")\n");
            }

            Culture.SetCurrentCulture();


            configSource.Alias.AddAlias("On", true);
            configSource.Alias.AddAlias("Off", false);
            configSource.Alias.AddAlias("True", true);
            configSource.Alias.AddAlias("False", false);

            configSource.AddSwitch("Startup", "background");
            configSource.AddSwitch("Startup", "inifile");
            configSource.AddSwitch("Startup", "inimaster");
            configSource.AddSwitch("Startup", "inidirectory");
            configSource.AddSwitch("Startup", "gridmode");
            configSource.AddSwitch("Startup", "physics");
            configSource.AddSwitch("Startup", "gui");

            configSource.AddConfig("StandAlone");
            configSource.AddConfig("Network");

            bool background = configSource.Configs["Startup"].GetBoolean("background", false);
            m_saveCrashDumps = configSource.Configs["Startup"].GetBoolean("save_crashes", false);
            m_crashDir = configSource.Configs["Startup"].GetString("crash_dir", m_crashDir);

            if (background)
            {
                m_sim = new OpenSimBackground(configSource);
                m_sim.Startup();
            }
            else
            {
                m_sim = new OpenSim(configSource);

                m_sim.Startup();

                while (true)
                {
                    try
                    {
                        MainConsole.Instance.Prompt();
                    }
                    catch (Exception e)
                    {
                        m_log.ErrorFormat("Command error: {0}", e);
                    }
                }
            }
        }