From 134f86e8d5c414409631b25b8c6f0ee45fbd8631 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Thu, 3 Nov 2016 21:44:39 +1000 Subject: Initial update to OpenSim 0.8.2.1 source code. --- OpenSim/Server/Base/HttpServerBase.cs | 39 +++++++------- OpenSim/Server/Base/Properties/AssemblyInfo.cs | 4 +- OpenSim/Server/Base/ProtocolVersions.cs | 8 +-- OpenSim/Server/Base/ServerUtils.cs | 53 +++++++++--------- OpenSim/Server/Base/ServicesServerBase.cs | 74 +++++++++++--------------- 5 files changed, 87 insertions(+), 91 deletions(-) (limited to 'OpenSim/Server/Base') diff --git a/OpenSim/Server/Base/HttpServerBase.cs b/OpenSim/Server/Base/HttpServerBase.cs index 954783c..44ef124 100644 --- a/OpenSim/Server/Base/HttpServerBase.cs +++ b/OpenSim/Server/Base/HttpServerBase.cs @@ -56,15 +56,16 @@ namespace OpenSim.Server.Base if (networkConfig == null) { - System.Console.WriteLine("Section 'Network' not found, server can't start"); - Thread.CurrentThread.Abort(); + System.Console.WriteLine("ERROR: Section [Network] not found, server can't start"); + Environment.Exit(1); } uint port = (uint)networkConfig.GetInt("port", 0); if (port == 0) { - Thread.CurrentThread.Abort(); + System.Console.WriteLine("ERROR: No 'port' entry found in [Network]. Server can't start"); + Environment.Exit(1); } bool ssl_main = networkConfig.GetBoolean("https_main",false); @@ -83,23 +84,24 @@ namespace OpenSim.Server.Base // Then, check for https settings and ADD a server to // m_Servers // - if ( !ssl_main ) + if (!ssl_main) { httpServer = new BaseHttpServer(port); } else { string cert_path = networkConfig.GetString("cert_path",String.Empty); - if ( cert_path == String.Empty ) + if (cert_path == String.Empty) { - System.Console.WriteLine("Path to X509 certificate is missing, server can't start."); - Thread.CurrentThread.Abort(); + System.Console.WriteLine("ERROR: Path to X509 certificate is missing, server can't start."); + Environment.Exit(1); } + string cert_pass = networkConfig.GetString("cert_pass",String.Empty); - if ( cert_pass == String.Empty ) + if (cert_pass == String.Empty) { - System.Console.WriteLine("Password for X509 certificate is missing, server can't start."); - Thread.CurrentThread.Abort(); + System.Console.WriteLine("ERROR: Password for X509 certificate is missing, server can't start."); + Environment.Exit(1); } httpServer = new BaseHttpServer(port, ssl_main, cert_path, cert_pass); @@ -109,21 +111,22 @@ namespace OpenSim.Server.Base MainServer.Instance = httpServer; // If https_listener = true, then add an ssl listener on the https_port... - if ( ssl_listener == true ) { - + if (ssl_listener == true) + { uint https_port = (uint)networkConfig.GetInt("https_port", 0); string cert_path = networkConfig.GetString("cert_path",String.Empty); - if ( cert_path == String.Empty ) + if (cert_path == String.Empty) { - System.Console.WriteLine("Path to X509 certificate is missing, server can't start."); - Thread.CurrentThread.Abort(); + System.Console.WriteLine("ERROR: Path to X509 certificate is missing, server can't start."); + Environment.Exit(1); } + string cert_pass = networkConfig.GetString("cert_pass",String.Empty); - if ( cert_pass == String.Empty ) + if (cert_pass == String.Empty) { - System.Console.WriteLine("Password for X509 certificate is missing, server can't start."); - Thread.CurrentThread.Abort(); + System.Console.WriteLine("ERROR: Password for X509 certificate is missing, server can't start."); + Environment.Exit(1); } MainServer.AddHttpServer(new BaseHttpServer(https_port, ssl_listener, cert_path, cert_pass)); diff --git a/OpenSim/Server/Base/Properties/AssemblyInfo.cs b/OpenSim/Server/Base/Properties/AssemblyInfo.cs index 4bbe358..3c634a7 100644 --- a/OpenSim/Server/Base/Properties/AssemblyInfo.cs +++ b/OpenSim/Server/Base/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("0.7.5.*")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("0.8.3.*")] + diff --git a/OpenSim/Server/Base/ProtocolVersions.cs b/OpenSim/Server/Base/ProtocolVersions.cs index 8db5bb6..5c2278c 100644 --- a/OpenSim/Server/Base/ProtocolVersions.cs +++ b/OpenSim/Server/Base/ProtocolVersions.cs @@ -46,11 +46,11 @@ namespace OpenSim.Server.Base /// // The range of acceptable servers for client-side connectors - public readonly static int ClientProtocolVersionMin = 0; - public readonly static int ClientProtocolVersionMax = 0; + public readonly static int ClientProtocolVersionMin = 1; + public readonly static int ClientProtocolVersionMax = 1; // The range of acceptable clients in server-side handlers - public readonly static int ServerProtocolVersionMin = 0; - public readonly static int ServerProtocolVersionMax = 0; + public readonly static int ServerProtocolVersionMin = 1; + public readonly static int ServerProtocolVersionMax = 1; } } diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs index 2e6d279..18a4266 100644 --- a/OpenSim/Server/Base/ServerUtils.cs +++ b/OpenSim/Server/Base/ServerUtils.cs @@ -41,7 +41,7 @@ using OpenSim.Framework.Servers.HttpServer; using OpenSim.Framework.Servers; -[assembly:AddinRoot("Robust", "0.1")] +[assembly:AddinRoot("Robust", OpenSim.VersionInfo.VersionNumber)] namespace OpenSim.Server.Base { [TypeExtensionPoint(Path="/Robust/Connector", Name="RobustConnector")] @@ -89,9 +89,9 @@ namespace OpenSim.Server.Base Config = config; Registry = new AddinRegistry(registryPath, "."); - suppress_console_output_(true); + //suppress_console_output_(true); AddinManager.Initialize(registryPath); - suppress_console_output_(false); + //suppress_console_output_(false); AddinManager.Registry.Update(); CommandManager commandmanager = new CommandManager(Registry); AddinManager.AddExtensionNodeHandler("/Robust/Connector", OnExtensionChanged); @@ -138,17 +138,17 @@ namespace OpenSim.Server.Base case ExtensionChange.Add: if (a.AddinFile.Contains(Registry.DefaultAddinsFolder)) { - m_log.InfoFormat("[SERVER]: Adding {0} from registry", a.Name); + m_log.InfoFormat("[SERVER UTILS]: Adding {0} from registry", a.Name); connector.PluginPath = System.IO.Path.Combine(Registry.DefaultAddinsFolder,a.Name.Replace(',', '.')); } else { - m_log.InfoFormat("[SERVER]: Adding {0} from ./bin", a.Name); + m_log.InfoFormat("[SERVER UTILS]: Adding {0} from ./bin", a.Name); connector.PluginPath = a.AddinFile; } LoadPlugin(connector); break; case ExtensionChange.Remove: - m_log.InfoFormat("[SERVER]: Removing {0}", a.Name); + m_log.InfoFormat("[SERVER UTILS]: Removing {0}", a.Name); UnloadPlugin(connector); break; } @@ -166,13 +166,13 @@ namespace OpenSim.Server.Base } else { - m_log.InfoFormat("[SERVER]: {0} Disabled.", connector.ConfigName); + m_log.InfoFormat("[SERVER UTILS]: {0} Disabled.", connector.ConfigName); } } private void UnloadPlugin(IRobustConnector connector) { - m_log.InfoFormat("[Server]: Unloading {0}", connector.ConfigName); + m_log.InfoFormat("[SERVER UTILS]: Unloading {0}", connector.ConfigName); connector.Unload(); } @@ -196,17 +196,19 @@ namespace OpenSim.Server.Base public static byte[] SerializeResult(XmlSerializer xs, object data) { - MemoryStream ms = new MemoryStream(); - XmlTextWriter xw = new XmlTextWriter(ms, Util.UTF8); - xw.Formatting = Formatting.Indented; - xs.Serialize(xw, data); - xw.Flush(); + using (MemoryStream ms = new MemoryStream()) + using (XmlTextWriter xw = new XmlTextWriter(ms, Util.UTF8)) + { + xw.Formatting = Formatting.Indented; + xs.Serialize(xw, data); + xw.Flush(); - ms.Seek(0, SeekOrigin.Begin); - byte[] ret = ms.GetBuffer(); - Array.Resize(ref ret, (int)ms.Length); + ms.Seek(0, SeekOrigin.Begin); + byte[] ret = ms.GetBuffer(); + Array.Resize(ref ret, (int)ms.Length); - return ret; + return ret; + } } /// @@ -266,7 +268,7 @@ namespace OpenSim.Server.Base && pluginType.ToString() != pluginType.Namespace + "." + className) continue; - Type typeInterface = pluginType.GetInterface(interfaceName, true); + Type typeInterface = pluginType.GetInterface(interfaceName); if (typeInterface != null) { @@ -280,12 +282,13 @@ namespace OpenSim.Server.Base { if (!(e is System.MissingMethodException)) { - m_log.ErrorFormat("Error loading plugin {0} from {1}. Exception: {2}, {3}", + m_log.Error(string.Format("[SERVER UTILS]: Error loading plugin {0} from {1}. Exception: {2}", interfaceName, dllName, - e.InnerException == null ? e.Message : e.InnerException.Message, - e.StackTrace); + e.InnerException == null ? e.Message : e.InnerException.Message), + e); } + m_log.ErrorFormat("[SERVER UTILS]: Error loading plugin {0}: {1} args.Length {2}", dllName, e.Message, args.Length); return null; } @@ -298,14 +301,14 @@ namespace OpenSim.Server.Base } catch (ReflectionTypeLoadException rtle) { - m_log.Error(string.Format("Error loading plugin from {0}:\n{1}", dllName, + m_log.Error(string.Format("[SERVER UTILS]: Error loading plugin from {0}:\n{1}", dllName, String.Join("\n", Array.ConvertAll(rtle.LoaderExceptions, e => e.ToString()))), rtle); return null; } catch (Exception e) { - m_log.Error(string.Format("Error loading plugin from {0}", dllName), e); + m_log.Error(string.Format("[SERVER UTILS]: Error loading plugin from {0}", dllName), e); return null; } } @@ -517,7 +520,7 @@ namespace OpenSim.Server.Base public static IConfigSource LoadInitialConfig(string url) { IConfigSource source = new XmlConfigSource(); - m_log.InfoFormat("[CONFIG]: {0} is a http:// URI, fetching ...", url); + m_log.InfoFormat("[SERVER UTILS]: {0} is a http:// URI, fetching ...", url); // The ini file path is a http URI // Try to read it @@ -529,7 +532,7 @@ namespace OpenSim.Server.Base } catch (Exception e) { - m_log.FatalFormat("[CONFIG]: Exception reading config from URI {0}\n" + e.ToString(), url); + m_log.FatalFormat("[SERVER UTILS]: Exception reading config from URI {0}\n" + e.ToString(), url); Environment.Exit(1); } diff --git a/OpenSim/Server/Base/ServicesServerBase.cs b/OpenSim/Server/Base/ServicesServerBase.cs index ecd69b0..1f2c54d 100644 --- a/OpenSim/Server/Base/ServicesServerBase.cs +++ b/OpenSim/Server/Base/ServicesServerBase.cs @@ -34,6 +34,7 @@ using System.Text; using System.Xml; using OpenSim.Framework; using OpenSim.Framework.Console; +using OpenSim.Framework.Monitoring; using OpenSim.Framework.Servers; using log4net; using log4net.Config; @@ -48,9 +49,7 @@ namespace OpenSim.Server.Base { // Logger // - private static readonly ILog m_log = - LogManager.GetLogger( - MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); // Command line args // @@ -71,11 +70,9 @@ namespace OpenSim.Server.Base public ServicesServerBase(string prompt, string[] args) : base() { // Save raw arguments - // m_Arguments = args; // Read command line - // ArgvConfigSource argvConfig = new ArgvConfigSource(args); argvConfig.AddSwitch("Startup", "console", "c"); @@ -85,8 +82,9 @@ namespace OpenSim.Server.Base argvConfig.AddSwitch("Startup", "logconfig", "g"); // Automagically create the ini file name - // - string fileName = Path.GetFileNameWithoutExtension(Assembly.GetEntryAssembly().Location); + string fileName = ""; + if (Assembly.GetEntryAssembly() != null) + fileName = Path.GetFileNameWithoutExtension(Assembly.GetEntryAssembly().Location); string iniFile = fileName + ".ini"; string logConfig = null; @@ -94,19 +92,17 @@ namespace OpenSim.Server.Base if (startupConfig != null) { // Check if a file name was given on the command line - // iniFile = startupConfig.GetString("inifile", iniFile); - // + // Check if a prompt was given on the command line prompt = startupConfig.GetString("prompt", prompt); - // + // Check for a Log4Net config file on the command line - logConfig =startupConfig.GetString("logconfig",logConfig); + logConfig =startupConfig.GetString("logconfig", logConfig); } - // Find out of the file name is a URI and remote load it - // if it's possible. Load it as a local file otherwise. - // + // Find out of the file name is a URI and remote load it if possible. + // Load it as a local file otherwise. Uri configUri; try @@ -128,13 +124,16 @@ namespace OpenSim.Server.Base Environment.Exit(1); } - // Merge the configuration from the command line into the - // loaded file - // + // Merge OpSys env vars + m_log.Info("[CONFIG]: Loading environment variables for Config"); + Util.MergeEnvironmentToConfig(Config); + + // Merge the configuration from the command line into the loaded file Config.Merge(argvConfig); + Config.ReplaceKeyValues(); + // Refresh the startupConfig post merge - // if (Config.Configs["Startup"] != null) { startupConfig = Config.Configs["Startup"]; @@ -144,13 +143,10 @@ namespace OpenSim.Server.Base prompt = startupConfig.GetString("Prompt", prompt); - // Allow derived classes to load config before the console is - // opened. - // + // Allow derived classes to load config before the console is opened. ReadConfig(); // Create main console - // string consoleType = "local"; if (startupConfig != null) consoleType = startupConfig.GetString("console", consoleType); @@ -164,18 +160,17 @@ namespace OpenSim.Server.Base MainConsole.Instance = new RemoteConsole(prompt); ((RemoteConsole)MainConsole.Instance).ReadConfig(Config); } - else + else if (consoleType == "mock") + { + MainConsole.Instance = new MockConsole(); + } + else if (consoleType == "local") { - MainConsole.Instance = new LocalConsole(prompt); + MainConsole.Instance = new LocalConsole(prompt, startupConfig); } m_console = MainConsole.Instance; - // Configure the appenders for log4net - // - OpenSimAppender consoleAppender = null; - FileAppender fileAppender = null; - if (logConfig != null) { FileInfo cfg = new FileInfo(logConfig); @@ -186,6 +181,7 @@ namespace OpenSim.Server.Base XmlConfigurator.Configure(); } + LogEnvironmentInformation(); RegisterCommonAppenders(startupConfig); if (startupConfig.GetString("PIDFile", String.Empty) != String.Empty) @@ -194,20 +190,10 @@ namespace OpenSim.Server.Base } RegisterCommonCommands(); - - // Register the quit command - // - MainConsole.Instance.Commands.AddCommand("General", false, "quit", - "quit", - "Quit the application", HandleQuit); - - MainConsole.Instance.Commands.AddCommand("General", false, "shutdown", - "shutdown", - "Quit the application", HandleQuit); + RegisterCommonComponents(Config); // Allow derived classes to perform initialization that // needs to be done after the console has opened - // Initialise(); } @@ -218,6 +204,9 @@ namespace OpenSim.Server.Base public virtual int Run() { + Watchdog.Enabled = true; + MemoryWatchdog.Enabled = true; + while (m_Running) { try @@ -235,11 +224,12 @@ namespace OpenSim.Server.Base return 0; } - protected virtual void HandleQuit(string module, string[] args) + protected override void ShutdownSpecific() { m_Running = false; m_log.Info("[CONSOLE] Quitting"); + base.ShutdownSpecific(); } protected virtual void ReadConfig() @@ -250,4 +240,4 @@ namespace OpenSim.Server.Base { } } -} +} \ No newline at end of file -- cgit v1.1