diff options
Diffstat (limited to 'OpenSim/Framework/Servers/BaseOpenSimServer.cs')
-rw-r--r-- | OpenSim/Framework/Servers/BaseOpenSimServer.cs | 82 |
1 files changed, 34 insertions, 48 deletions
diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs index c0dc907..828a852 100644 --- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs +++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs | |||
@@ -45,6 +45,7 @@ using OpenSim.Framework.Monitoring; | |||
45 | using OpenSim.Framework.Servers; | 45 | using OpenSim.Framework.Servers; |
46 | using OpenSim.Framework.Servers.HttpServer; | 46 | using OpenSim.Framework.Servers.HttpServer; |
47 | using Timer=System.Timers.Timer; | 47 | using Timer=System.Timers.Timer; |
48 | using Nini.Config; | ||
48 | 49 | ||
49 | namespace OpenSim.Framework.Servers | 50 | namespace OpenSim.Framework.Servers |
50 | { | 51 | { |
@@ -56,9 +57,15 @@ namespace OpenSim.Framework.Servers | |||
56 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 57 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
57 | 58 | ||
58 | /// <summary> | 59 | /// <summary> |
60 | /// Used by tests to suppress Environment.Exit(0) so that post-run operations are possible. | ||
61 | /// </summary> | ||
62 | public bool SuppressExit { get; set; } | ||
63 | |||
64 | /// <summary> | ||
59 | /// This will control a periodic log printout of the current 'show stats' (if they are active) for this | 65 | /// This will control a periodic log printout of the current 'show stats' (if they are active) for this |
60 | /// server. | 66 | /// server. |
61 | /// </summary> | 67 | /// </summary> |
68 | private int m_periodDiagnosticTimerMS = 60 * 60 * 1000; | ||
62 | private Timer m_periodicDiagnosticsTimer = new Timer(60 * 60 * 1000); | 69 | private Timer m_periodicDiagnosticsTimer = new Timer(60 * 60 * 1000); |
63 | 70 | ||
64 | /// <summary> | 71 | /// <summary> |
@@ -77,8 +84,6 @@ namespace OpenSim.Framework.Servers | |||
77 | // Random uuid for private data | 84 | // Random uuid for private data |
78 | m_osSecret = UUID.Random().ToString(); | 85 | m_osSecret = UUID.Random().ToString(); |
79 | 86 | ||
80 | m_periodicDiagnosticsTimer.Elapsed += new ElapsedEventHandler(LogDiagnostics); | ||
81 | m_periodicDiagnosticsTimer.Enabled = true; | ||
82 | } | 87 | } |
83 | 88 | ||
84 | /// <summary> | 89 | /// <summary> |
@@ -86,26 +91,34 @@ namespace OpenSim.Framework.Servers | |||
86 | /// </summary> | 91 | /// </summary> |
87 | protected virtual void StartupSpecific() | 92 | protected virtual void StartupSpecific() |
88 | { | 93 | { |
89 | if (m_console == null) | 94 | StatsManager.SimExtraStats = new SimExtraStatsCollector(); |
90 | return; | ||
91 | |||
92 | RegisterCommonCommands(); | 95 | RegisterCommonCommands(); |
93 | 96 | RegisterCommonComponents(Config); | |
94 | m_console.Commands.AddCommand("General", false, "quit", | 97 | |
95 | "quit", | 98 | IConfig startupConfig = Config.Configs["Startup"]; |
96 | "Quit the application", HandleQuit); | 99 | int logShowStatsSeconds = startupConfig.GetInt("LogShowStatsSeconds", m_periodDiagnosticTimerMS / 1000); |
100 | m_periodDiagnosticTimerMS = logShowStatsSeconds * 1000; | ||
101 | m_periodicDiagnosticsTimer.Elapsed += new ElapsedEventHandler(LogDiagnostics); | ||
102 | if (m_periodDiagnosticTimerMS != 0) | ||
103 | { | ||
104 | m_periodicDiagnosticsTimer.Interval = m_periodDiagnosticTimerMS; | ||
105 | m_periodicDiagnosticsTimer.Enabled = true; | ||
106 | } | ||
107 | } | ||
108 | |||
109 | protected override void ShutdownSpecific() | ||
110 | { | ||
111 | m_log.Info("[SHUTDOWN]: Shutdown processing on main thread complete. Exiting..."); | ||
97 | 112 | ||
98 | m_console.Commands.AddCommand("General", false, "shutdown", | 113 | RemovePIDFile(); |
99 | "shutdown", | 114 | |
100 | "Quit the application", HandleQuit); | 115 | base.ShutdownSpecific(); |
116 | |||
117 | if (!SuppressExit) | ||
118 | Environment.Exit(0); | ||
101 | } | 119 | } |
102 | 120 | ||
103 | /// <summary> | 121 | /// <summary> |
104 | /// Should be overriden and referenced by descendents if they need to perform extra shutdown processing | ||
105 | /// </summary> | ||
106 | public virtual void ShutdownSpecific() {} | ||
107 | |||
108 | /// <summary> | ||
109 | /// Provides a list of help topics that are available. Overriding classes should append their topics to the | 122 | /// Provides a list of help topics that are available. Overriding classes should append their topics to the |
110 | /// information returned when the base method is called. | 123 | /// information returned when the base method is called. |
111 | /// </summary> | 124 | /// </summary> |
@@ -133,45 +146,18 @@ namespace OpenSim.Framework.Servers | |||
133 | /// Performs initialisation of the scene, such as loading configuration from disk. | 146 | /// Performs initialisation of the scene, such as loading configuration from disk. |
134 | /// </summary> | 147 | /// </summary> |
135 | public virtual void Startup() | 148 | public virtual void Startup() |
136 | { | 149 | { |
137 | m_log.Info("[STARTUP]: Beginning startup processing"); | ||
138 | |||
139 | m_log.Info("[STARTUP]: OpenSimulator version: " + m_version + Environment.NewLine); | ||
140 | // clr version potentially is more confusing than helpful, since it doesn't tell us if we're running under Mono/MS .NET and | ||
141 | // the clr version number doesn't match the project version number under Mono. | ||
142 | //m_log.Info("[STARTUP]: Virtual machine runtime version: " + Environment.Version + Environment.NewLine); | ||
143 | m_log.InfoFormat( | ||
144 | "[STARTUP]: Operating system version: {0}, .NET platform {1}, {2}-bit\n", | ||
145 | Environment.OSVersion, Environment.OSVersion.Platform, Util.Is64BitProcess() ? "64" : "32"); | ||
146 | |||
147 | StartupSpecific(); | 150 | StartupSpecific(); |
148 | 151 | ||
149 | TimeSpan timeTaken = DateTime.Now - m_startuptime; | 152 | TimeSpan timeTaken = DateTime.Now - m_startuptime; |
150 | 153 | ||
151 | m_log.InfoFormat( | 154 | MainConsole.Instance.OutputFormat( |
152 | "[STARTUP]: Non-script portion of startup took {0}m {1}s. PLEASE WAIT FOR LOGINS TO BE ENABLED ON REGIONS ONCE SCRIPTS HAVE STARTED.", | 155 | "PLEASE WAIT FOR LOGINS TO BE ENABLED ON REGIONS ONCE SCRIPTS HAVE STARTED. Non-script portion of startup took {0}m {1}s.", |
153 | timeTaken.Minutes, timeTaken.Seconds); | 156 | timeTaken.Minutes, timeTaken.Seconds); |
154 | } | 157 | } |
155 | 158 | ||
156 | /// <summary> | 159 | public string osSecret |
157 | /// Should be overriden and referenced by descendents if they need to perform extra shutdown processing | ||
158 | /// </summary> | ||
159 | public virtual void Shutdown() | ||
160 | { | 160 | { |
161 | ShutdownSpecific(); | ||
162 | |||
163 | m_log.Info("[SHUTDOWN]: Shutdown processing on main thread complete. Exiting..."); | ||
164 | RemovePIDFile(); | ||
165 | |||
166 | Environment.Exit(0); | ||
167 | } | ||
168 | |||
169 | private void HandleQuit(string module, string[] args) | ||
170 | { | ||
171 | Shutdown(); | ||
172 | } | ||
173 | |||
174 | public string osSecret { | ||
175 | // Secret uuid for the simulator | 161 | // Secret uuid for the simulator |
176 | get { return m_osSecret; } | 162 | get { return m_osSecret; } |
177 | } | 163 | } |