mirror of
https://github.com/opensim/opensim.git
synced 2026-08-11 11:57:03 +08:00
missing sql code plus cosmetics
This commit is contained in:
@@ -73,11 +73,25 @@ namespace OpenSim
|
||||
// First line, hook the appdomain to the crash reporter
|
||||
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
|
||||
|
||||
System.AppContext.SetSwitch("System.Drawing.EnableUnixSupport", true);
|
||||
|
||||
Culture.SetCurrentCulture();
|
||||
Culture.SetDefaultCurrentCulture();
|
||||
|
||||
AppContext.SetSwitch("System.Drawing.EnableUnixSupport", true);
|
||||
|
||||
// pre load System.Drawing.Common.dll for the platform
|
||||
// this will fail if a newer version is present on GAC, bin folder, etc, since LoadFrom only accepts the path, if it cannot find it elsewhere
|
||||
string targetdll = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),"lib",
|
||||
(Util.IsWindows() ? "win" : "linux"), "System.Drawing.Common.dll");
|
||||
try
|
||||
{
|
||||
Assembly asmb = Assembly.LoadFrom(targetdll);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error("Failed to load System.Drawing.Common.dll for current platform" + e.Message);
|
||||
throw;
|
||||
}
|
||||
|
||||
ServicePointManager.DefaultConnectionLimit = 32;
|
||||
ServicePointManager.MaxServicePointIdleTime = 30000;
|
||||
|
||||
@@ -94,8 +108,7 @@ namespace OpenSim
|
||||
if (!string.IsNullOrEmpty(logConfigFile))
|
||||
{
|
||||
XmlConfigurator.Configure(new System.IO.FileInfo(logConfigFile));
|
||||
m_log.InfoFormat("[OPENSIM MAIN]: configured log4net using \"{0}\" as configuration file",
|
||||
logConfigFile);
|
||||
m_log.Info($"[OPENSIM MAIN]: configured log4net using \"{logConfigFile}\" as configuration file");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -103,66 +116,29 @@ namespace OpenSim
|
||||
m_log.Info("[OPENSIM MAIN]: configured log4net using default OpenSim.exe.config");
|
||||
}
|
||||
|
||||
// temporay set the platform dependent System.Drawing.Common.dll
|
||||
string targetdll = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
|
||||
"System.Drawing.Common.dll");
|
||||
string src = targetdll + (Util.IsWindows() ? ".win" : ".linux");
|
||||
try
|
||||
{
|
||||
if (!File.Exists(targetdll))
|
||||
File.Copy(src, targetdll);
|
||||
else
|
||||
{
|
||||
FileInfo targetInfo = new(targetdll);
|
||||
FileInfo srcInfo = new(src);
|
||||
if(targetInfo.Length != srcInfo.Length)
|
||||
File.Copy(src, targetdll, true);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error("Failed to copy System.Drawing.Common.dll for current platform" + e.Message);
|
||||
throw;
|
||||
}
|
||||
m_log.Info($"[OPENSIM MAIN]: System Locale is {System.Threading.Thread.CurrentThread.CurrentCulture}");
|
||||
|
||||
m_log.InfoFormat(
|
||||
"[OPENSIM MAIN]: System Locale is {0}", System.Threading.Thread.CurrentThread.CurrentCulture);
|
||||
if(!Util.IsWindows())
|
||||
{
|
||||
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 workerThreadsMax = 1000;
|
||||
int iocpThreadsMin = 1000;
|
||||
int iocpThreadsMax = 2000; // may need further adjustment to match other CLR
|
||||
int iocpThreadsMax = 2000;
|
||||
|
||||
System.Threading.ThreadPool.GetMinThreads(out int currentMinWorkerThreads, out int currentMinIocpThreads);
|
||||
m_log.InfoFormat(
|
||||
"[OPENSIM MAIN]: Runtime gave us {0} min worker threads and {1} min IOCP threads",
|
||||
currentMinWorkerThreads, currentMinIocpThreads);
|
||||
m_log.Info(
|
||||
$"[OPENSIM MAIN]: Runtime gave us {currentMinWorkerThreads} min worker threads and {currentMinIocpThreads} min IOCP threads");
|
||||
|
||||
System.Threading.ThreadPool.GetMaxThreads(out int workerThreads, out int iocpThreads);
|
||||
m_log.InfoFormat("[OPENSIM MAIN]: Runtime gave us {0} max worker threads and {1} max IOCP threads", workerThreads, iocpThreads);
|
||||
m_log.Info($"[OPENSIM MAIN]: Runtime gave us {workerThreads} max worker threads and {iocpThreads} max IOCP threads");
|
||||
|
||||
if (workerThreads < workerThreadsMin)
|
||||
{
|
||||
workerThreads = workerThreadsMin;
|
||||
m_log.InfoFormat("[OPENSIM MAIN]: Bumping up max worker threads to {0}",workerThreads);
|
||||
m_log.Info($"[OPENSIM MAIN]: Bumping up max worker threads to {workerThreads}");
|
||||
}
|
||||
if (workerThreads > workerThreadsMax)
|
||||
{
|
||||
workerThreads = workerThreadsMax;
|
||||
m_log.InfoFormat("[OPENSIM MAIN]: Limiting max worker threads to {0}",workerThreads);
|
||||
m_log.Info($"[OPENSIM MAIN]: Limiting max worker threads to {workerThreads}");
|
||||
}
|
||||
|
||||
// Increase the number of IOCP threads available.
|
||||
@@ -170,20 +146,19 @@ namespace OpenSim
|
||||
if (iocpThreads < iocpThreadsMin)
|
||||
{
|
||||
iocpThreads = iocpThreadsMin;
|
||||
m_log.InfoFormat("[OPENSIM MAIN]: Bumping up max IOCP threads to {0}",iocpThreads);
|
||||
m_log.Info($"[OPENSIM MAIN]: Bumping up max IOCP threads to {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);
|
||||
m_log.Info($"[OPENSIM MAIN]: Limiting max IOCP completion threads to {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);
|
||||
m_log.Info(
|
||||
$"[OPENSIM MAIN]: Threadpool set to {workerThreads} max worker threads and {iocpThreads} max IOCP threads");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -192,17 +167,17 @@ namespace OpenSim
|
||||
|
||||
// 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))
|
||||
string error = string.Empty;
|
||||
if (Util.IsEnvironmentSupported(ref error))
|
||||
{
|
||||
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.Warn($"[OPENSIM MAIN]: Environment is not supported by OpenSimulator: {error}\n");
|
||||
}
|
||||
|
||||
m_log.InfoFormat("Default culture changed to {0}",Culture.GetDefaultCurrentCulture().DisplayName);
|
||||
m_log.Info($"Default culture changed to {Culture.GetDefaultCurrentCulture().DisplayName}");
|
||||
|
||||
// Configure nIni aliases and localles
|
||||
|
||||
@@ -362,7 +337,7 @@ namespace OpenSim
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat("Command error: {0}", e);
|
||||
m_log.Error($"Command error: {e}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -386,22 +361,19 @@ namespace OpenSim
|
||||
// TODO: Add config option to allow users to turn off error reporting
|
||||
// TODO: Post error report (disabled for now)
|
||||
|
||||
string msg = String.Empty;
|
||||
msg += "\r\n";
|
||||
msg += "APPLICATION EXCEPTION DETECTED: " + e.ToString() + "\r\n";
|
||||
msg += "\r\n";
|
||||
string msg = $"\r\nAPPLICATION EXCEPTION DETECTED: {e}\r\n\r\n";
|
||||
|
||||
msg += "Exception: " + e.ExceptionObject.ToString() + "\r\n";
|
||||
Exception ex = (Exception) e.ExceptionObject;
|
||||
Exception ex = (Exception)e.ExceptionObject;
|
||||
|
||||
msg += $"Exception: {ex}\r\n";
|
||||
if (ex.InnerException != null)
|
||||
{
|
||||
msg += "InnerException: " + ex.InnerException.ToString() + "\r\n";
|
||||
msg += $"InnerException: {ex.InnerException}\r\n";
|
||||
}
|
||||
|
||||
msg += "\r\n";
|
||||
msg += "Application is terminating: " + e.IsTerminating.ToString() + "\r\n";
|
||||
msg += $"\r\nApplication is terminating: {e.IsTerminating}\r\n";
|
||||
|
||||
m_log.ErrorFormat("[APPLICATION]: {0}", msg);
|
||||
m_log.Error("[APPLICATION]: + msg");
|
||||
|
||||
if (m_saveCrashDumps)
|
||||
{
|
||||
@@ -422,7 +394,7 @@ namespace OpenSim
|
||||
}
|
||||
catch (Exception e2)
|
||||
{
|
||||
m_log.ErrorFormat("[CRASH LOGGER CRASHED]: {0}", e2);
|
||||
m_log.Error($"[CRASH LOGGER CRASHED]: {e2}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user