diff options
author | Justin Clarke Casey | 2008-04-29 14:50:27 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2008-04-29 14:50:27 +0000 |
commit | 763ae779ffb43ea9d33a9bf2a1c6c4ca78ef243d (patch) | |
tree | ade4e916a83e25d286c9e2cf95721bf5b366910e | |
parent | Committing Dee100's balance update patch with a few bug fixes and a twist. Th... (diff) | |
download | opensim-SC-763ae779ffb43ea9d33a9bf2a1c6c4ca78ef243d.zip opensim-SC-763ae779ffb43ea9d33a9bf2a1c6c4ca78ef243d.tar.gz opensim-SC-763ae779ffb43ea9d33a9bf2a1c6c4ca78ef243d.tar.bz2 opensim-SC-763ae779ffb43ea9d33a9bf2a1c6c4ca78ef243d.tar.xz |
From: Dr Scofield <hud@zurich.ibm.com>
* Fixes the admin_shutdown xmlrpc method
* Adds a share/python/console/shutdown.py script for shutting down a background OpenSim
* For more details see http://xyzzyxyzzy.net/2008/04/29/console-less-opensim/
* There should also be instructions in the opensimulator wiki soon as well
-rw-r--r-- | OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs | 31 | ||||
-rw-r--r-- | OpenSim/Region/Application/Application.cs | 1 | ||||
-rw-r--r-- | OpenSim/Region/Application/OpenSimMain.cs | 14 | ||||
-rw-r--r-- | share/python/console/shutdown.py | 39 |
4 files changed, 62 insertions, 23 deletions
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index 2cb5375..fed7d9b 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs | |||
@@ -218,9 +218,6 @@ namespace OpenSim.ApplicationPlugins.LoadRegions | |||
218 | Hashtable responseData = new Hashtable(); | 218 | Hashtable responseData = new Hashtable(); |
219 | 219 | ||
220 | try { | 220 | try { |
221 | checkStringParameters(request, new string[] { "password", "shutdown" }); | ||
222 | checkIntegerParams(request, new string[] { "milliseconds"}); | ||
223 | |||
224 | if (requiredPassword != String.Empty && | 221 | if (requiredPassword != String.Empty && |
225 | (!requestData.Contains("password") || (string) requestData["password"] != requiredPassword)) | 222 | (!requestData.Contains("password") || (string) requestData["password"] != requiredPassword)) |
226 | throw new Exception("wrong password"); | 223 | throw new Exception("wrong password"); |
@@ -228,28 +225,28 @@ namespace OpenSim.ApplicationPlugins.LoadRegions | |||
228 | responseData["accepted"] = "true"; | 225 | responseData["accepted"] = "true"; |
229 | response.Value = responseData; | 226 | response.Value = responseData; |
230 | 227 | ||
231 | if ((string) requestData["shutdown"] == "delayed") | 228 | int timeout = 2000; |
229 | |||
230 | if (requestData.ContainsKey("shutdown") && | ||
231 | ((string) requestData["shutdown"] == "delayed") && | ||
232 | requestData.ContainsKey("milliseconds")) | ||
232 | { | 233 | { |
233 | int timeout = (Int32) requestData["milliseconds"]; | 234 | timeout = (Int32) requestData["milliseconds"]; |
234 | m_app.SceneManager.SendGeneralMessage("Region is going down in " + ((int) (timeout/1000)).ToString() + | 235 | m_app.SceneManager.SendGeneralMessage("Region is going down in " + ((int) (timeout/1000)).ToString() + |
235 | " second(s). Please save what you are doing and log out."); | 236 | " second(s). Please save what you are doing and log out."); |
236 | |||
237 | // Perform shutdown | ||
238 | Timer shutdownTimer = new Timer(timeout); // Wait before firing | ||
239 | shutdownTimer.AutoReset = false; | ||
240 | shutdownTimer.Elapsed += new ElapsedEventHandler(shutdownTimer_Elapsed); | ||
241 | shutdownTimer.Start(); | ||
242 | } | 237 | } |
243 | else | 238 | else |
244 | { | 239 | { |
245 | m_app.SceneManager.SendGeneralMessage("Region is going down now."); | 240 | m_app.SceneManager.SendGeneralMessage("Region is going down now."); |
246 | |||
247 | // Perform shutdown | ||
248 | Timer shutdownTimer = new Timer(2000); // Wait 2 seconds before firing | ||
249 | shutdownTimer.AutoReset = false; | ||
250 | shutdownTimer.Elapsed += new ElapsedEventHandler(shutdownTimer_Elapsed); | ||
251 | shutdownTimer.Start(); | ||
252 | } | 241 | } |
242 | |||
243 | // Perform shutdown | ||
244 | Timer shutdownTimer = new Timer(timeout); // Wait before firing | ||
245 | shutdownTimer.AutoReset = false; | ||
246 | shutdownTimer.Elapsed += new ElapsedEventHandler(shutdownTimer_Elapsed); | ||
247 | shutdownTimer.Start(); | ||
248 | |||
249 | responseData["success"] = "true"; | ||
253 | } | 250 | } |
254 | catch (Exception e) | 251 | catch (Exception e) |
255 | { | 252 | { |
diff --git a/OpenSim/Region/Application/Application.cs b/OpenSim/Region/Application/Application.cs index 828490a..bdce0f0 100644 --- a/OpenSim/Region/Application/Application.cs +++ b/OpenSim/Region/Application/Application.cs | |||
@@ -83,7 +83,6 @@ namespace OpenSim | |||
83 | 83 | ||
84 | if (background) | 84 | if (background) |
85 | { | 85 | { |
86 | Console.WriteLine("background mode"); | ||
87 | OpenSimMain sim = new OpenSimMain(configSource); | 86 | OpenSimMain sim = new OpenSimMain(configSource); |
88 | sim.StartUp(); | 87 | sim.StartUp(); |
89 | } | 88 | } |
diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index 3bee7f3..d05a632 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimMain.cs | |||
@@ -323,15 +323,19 @@ namespace OpenSim | |||
323 | // | 323 | // |
324 | // Called from app startup (OpenSim.Application) | 324 | // Called from app startup (OpenSim.Application) |
325 | // | 325 | // |
326 | 326 | m_log.Info("===================================================================="); | |
327 | m_log.Info("[OPENSIM]: Starting Opensim"); | 327 | m_log.Info("========================= STARTING OPENSIM ========================="); |
328 | m_log.InfoFormat("[OPENSIM MAIN]: Running in {0} mode", (m_sandbox ? "sandbox" : "grid")); | 328 | m_log.Info("===================================================================="); |
329 | m_log.InfoFormat("[OPENSIM MAIN]: Running in background {0} mode", m_sandbox ? "sandbox" : "grid"); | ||
329 | 330 | ||
330 | InternalStartUp(); | 331 | InternalStartUp(); |
331 | 332 | ||
332 | // We are done with startup | 333 | // We are done with startup |
333 | m_log.Info("[OPENSIM MAIN]: Startup complete, serving " + m_udpServers.Count.ToString() + " region(s)"); | 334 | m_log.InfoFormat("[OPENSIM MAIN]: Startup complete, serving {0} region{1}", |
335 | m_udpServers.Count.ToString(), m_udpServers.Count > 1 ? "s" : ""); | ||
334 | WorldHasComeToAnEnd.WaitOne(); | 336 | WorldHasComeToAnEnd.WaitOne(); |
337 | m_log.Info("[OPENSIM MAIN]: Shutdown complete, goodbye."); | ||
338 | Environment.Exit(0); | ||
335 | } | 339 | } |
336 | 340 | ||
337 | 341 | ||
@@ -684,7 +688,7 @@ namespace OpenSim | |||
684 | public virtual void Shutdown() | 688 | public virtual void Shutdown() |
685 | { | 689 | { |
686 | InternalShutdown(); | 690 | InternalShutdown(); |
687 | Environment.Exit(0); | 691 | ApocalypseNow(); |
688 | } | 692 | } |
689 | 693 | ||
690 | /// <summary> | 694 | /// <summary> |
diff --git a/share/python/console/shutdown.py b/share/python/console/shutdown.py new file mode 100644 index 0000000..65f8255 --- /dev/null +++ b/share/python/console/shutdown.py | |||
@@ -0,0 +1,39 @@ | |||
1 | #!/usr/bin/python | ||
2 | # -*- encoding: utf-8 -*- | ||
3 | |||
4 | import ConfigParser | ||
5 | import xmlrpclib | ||
6 | import optparse | ||
7 | import os.path | ||
8 | |||
9 | if __name__ == '__main__': | ||
10 | parser = optparse.OptionParser() | ||
11 | parser.add_option('-c', '--config', dest = 'config', help = 'config file', metavar = 'CONFIG') | ||
12 | parser.add_option('-s', '--server', dest = 'server', help = 'URI for the grid server', metavar = 'SERVER') | ||
13 | parser.add_option('-p', '--password', dest = 'password', help = 'password for the grid server', metavar = 'PASSWD') | ||
14 | (options, args) = parser.parse_args() | ||
15 | |||
16 | configFile = options.config | ||
17 | if not configFile: | ||
18 | if os.path.isfile(os.path.expanduser('~/.opensim-console.rc')): | ||
19 | configFile = os.path.expanduser('~/.opensim-console.rc') | ||
20 | if not configFile: | ||
21 | parser.error('missing option config') | ||
22 | sys.exit(1) | ||
23 | |||
24 | config = ConfigParser.ConfigParser() | ||
25 | config.readfp(open(configFile)) | ||
26 | |||
27 | server = config.get('opensim', 'server') | ||
28 | password = config.get('opensim', 'password') | ||
29 | |||
30 | if options.server: server = options.server | ||
31 | if options.password: password = options.password | ||
32 | |||
33 | gridServer = xmlrpclib.Server(server) | ||
34 | res = gridServer.admin_shutdown({'password': password}) | ||
35 | |||
36 | if res['success'] == 'true': | ||
37 | print 'shutdown of %s initiated' % server | ||
38 | else: | ||
39 | print 'shutdown of %s failed' % server | ||