From baefa05b575b28e1ed08670e9c937ca307f09269 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 4 Feb 2008 18:52:24 +0000 Subject: * Rebase all current servers on common abstract BaseOpenSimServer class * The immediate upshot is that "show uptime" from the console will now show uptime on all server types (user, asset, grid, etc) * DEV: This refactoring is far from complete - only just enough to makes the "show uptime" command common accross the servers. More is needed, but in this case it's somewhat like eating cabbage, which I prefer not to do all at once --- OpenSim/Grid/AssetServer/Main.cs | 44 ++++++++++++++------------- OpenSim/Grid/GridServer/Main.cs | 34 +++++++++------------ OpenSim/Grid/InventoryServer/Main.cs | 23 ++++++-------- OpenSim/Grid/MessagingServer/Main.cs | 27 ++++++++-------- OpenSim/Grid/ScriptServer/ScriptServerMain.cs | 14 ++------- OpenSim/Grid/UserServer/Main.cs | 43 ++++++++++++-------------- 6 files changed, 85 insertions(+), 100 deletions(-) (limited to 'OpenSim/Grid') diff --git a/OpenSim/Grid/AssetServer/Main.cs b/OpenSim/Grid/AssetServer/Main.cs index 23b0afa..a95ea71 100644 --- a/OpenSim/Grid/AssetServer/Main.cs +++ b/OpenSim/Grid/AssetServer/Main.cs @@ -41,13 +41,11 @@ namespace OpenSim.Grid.AssetServer /// /// An asset server /// - public class OpenAsset_Main : conscmd_callback + public class OpenAsset_Main : BaseOpenSimServer, conscmd_callback { public AssetConfig m_config; - public static OpenAsset_Main assetserver; - - private LogBase m_console; + public static OpenAsset_Main assetserver; // Temporarily hardcoded - should be a plugin protected IAssetLoader assetLoader = new AssetLoaderFileSystem(); @@ -67,11 +65,11 @@ namespace OpenSim.Grid.AssetServer private void Work() { - m_console.Notice("Enter help for a list of commands"); + m_log.Notice("Enter help for a list of commands"); while (true) { - m_console.MainLogPrompt(); + m_log.MainLogPrompt(); } } @@ -81,22 +79,28 @@ namespace OpenSim.Grid.AssetServer { Directory.CreateDirectory(Util.logDir()); } - m_console = - new LogBase((Path.Combine(Util.logDir(), "opengrid-AssetServer-console.log")), "OpenAsset", this, true); - MainLog.Instance = m_console; + + m_log = + new LogBase( + (Path.Combine(Util.logDir(), "opengrid-AssetServer-console.log")), + "OpenAsset", + this, + true); + + MainLog.Instance = m_log; } public void Startup() { m_config = new AssetConfig("ASSET SERVER", (Path.Combine(Util.configDir(), "AssetServer_Config.xml"))); - m_console.Verbose("ASSET", "Setting up asset DB"); + m_log.Verbose("ASSET", "Setting up asset DB"); setupDB(m_config); - m_console.Verbose("ASSET", "Loading default asset set.."); + m_log.Verbose("ASSET", "Loading default asset set.."); LoadDefaultAssets(); - m_console.Verbose("ASSET", "Starting HTTP process"); + m_log.Verbose("ASSET", "Starting HTTP process"); BaseHttpServer httpServer = new BaseHttpServer(m_config.HttpPort); StatsManager.StartCollectingAssetStats(); @@ -170,30 +174,28 @@ namespace OpenSim.Grid.AssetServer m_assetProvider.CreateAsset(asset); } - public void RunCmd(string cmd, string[] cmdparams) + public override void RunCmd(string cmd, string[] cmdparams) { + base.RunCmd(cmd, cmdparams); + switch (cmd) { case "help": - m_console.Notice( + m_log.Notice( @"shutdown - shutdown this asset server (USE CAUTION!) stats - statistical information for this server"); - break; + break; case "stats": - m_console.Notice("STATS", Environment.NewLine + StatsManager.AssetStats.Report()); + m_log.Notice("STATS", Environment.NewLine + StatsManager.AssetStats.Report()); break; case "shutdown": - m_console.Close(); + m_log.Close(); Environment.Exit(0); break; } } - - public void Show(string ShowWhat) - { - } } } diff --git a/OpenSim/Grid/GridServer/Main.cs b/OpenSim/Grid/GridServer/Main.cs index d4947b3..8a522c2 100644 --- a/OpenSim/Grid/GridServer/Main.cs +++ b/OpenSim/Grid/GridServer/Main.cs @@ -37,7 +37,7 @@ namespace OpenSim.Grid.GridServer { /// /// - public class OpenGrid_Main : conscmd_callback + public class OpenGrid_Main : BaseOpenSimServer, conscmd_callback { public GridConfig Cfg; @@ -51,8 +51,6 @@ namespace OpenSim.Grid.GridServer private GridManager m_gridManager; - private LogBase m_console; - [STAThread] public static void Main(string[] args) { @@ -70,11 +68,11 @@ namespace OpenSim.Grid.GridServer private void Work() { - m_console.Notice("Enter help for a list of commands\n"); + m_log.Notice("Enter help for a list of commands\n"); while (true) { - m_console.MainLogPrompt(); + m_log.MainLogPrompt(); } } @@ -84,9 +82,9 @@ namespace OpenSim.Grid.GridServer { Directory.CreateDirectory(Util.logDir()); } - m_console = + m_log = new LogBase((Path.Combine(Util.logDir(), "opengrid-gridserver-console.log")), "OpenGrid", this, true); - MainLog.Instance = m_console; + MainLog.Instance = m_log; } public void managercallback(string cmd) @@ -106,12 +104,12 @@ namespace OpenSim.Grid.GridServer //Yeah srsly, that's it. if (setuponly) Environment.Exit(0); - m_console.Verbose("GRID", "Connecting to Storage Server"); + m_log.Verbose("GRID", "Connecting to Storage Server"); m_gridManager = new GridManager(); m_gridManager.AddPlugin(Cfg.DatabaseProvider); // Made of win m_gridManager.config = Cfg; - m_console.Verbose("GRID", "Starting HTTP process"); + m_log.Verbose("GRID", "Starting HTTP process"); BaseHttpServer httpServer = new BaseHttpServer(Cfg.HttpPort); //GridManagementAgent GridManagerAgent = new GridManagementAgent(httpServer, "gridserver", Cfg.SimSendKey, Cfg.SimRecvKey, managercallback); @@ -137,7 +135,7 @@ namespace OpenSim.Grid.GridServer httpServer.Start(); - m_console.Verbose("GRID", "Starting sim status checker"); + m_log.Verbose("GRID", "Starting sim status checker"); Timer simCheckTimer = new Timer(3600000*3); // 3 Hours between updates. simCheckTimer.Elapsed += new ElapsedEventHandler(CheckSims); @@ -181,25 +179,23 @@ namespace OpenSim.Grid.GridServer */ } - public void RunCmd(string cmd, string[] cmdparams) + public override void RunCmd(string cmd, string[] cmdparams) { + base.RunCmd(cmd, cmdparams); + switch (cmd) { case "help": - m_console.Notice("shutdown - shutdown the grid (USE CAUTION!)"); - break; + m_log.Notice("shutdown - shutdown the grid (USE CAUTION!)"); + break; case "shutdown": - m_console.Close(); + m_log.Close(); Environment.Exit(0); break; } } - public void Show(string ShowWhat) - { - } - /*private void ConfigDB(IGenericConfig configData) { try @@ -223,4 +219,4 @@ namespace OpenSim.Grid.GridServer } }*/ } -} \ No newline at end of file +} diff --git a/OpenSim/Grid/InventoryServer/Main.cs b/OpenSim/Grid/InventoryServer/Main.cs index ce371bf..b62c696 100644 --- a/OpenSim/Grid/InventoryServer/Main.cs +++ b/OpenSim/Grid/InventoryServer/Main.cs @@ -36,9 +36,8 @@ using OpenSim.Framework.Servers; namespace OpenSim.Grid.InventoryServer { - public class OpenInventory_Main : conscmd_callback + public class OpenInventory_Main : BaseOpenSimServer, conscmd_callback { - private LogBase m_console; private InventoryManager m_inventoryManager; private InventoryConfig m_config; private GridInventoryService m_inventoryService; @@ -56,8 +55,8 @@ namespace OpenSim.Grid.InventoryServer public OpenInventory_Main() { - m_console = new LogBase("opengrid-inventory-console.log", LogName, this, true); - MainLog.Instance = m_console; + m_log = new LogBase("opengrid-inventory-console.log", LogName, this, true); + MainLog.Instance = m_log; } public void Startup() @@ -104,16 +103,18 @@ namespace OpenSim.Grid.InventoryServer private void Work() { - m_console.Notice("Enter help for a list of commands\n"); + m_log.Notice("Enter help for a list of commands\n"); while (true) { - m_console.MainLogPrompt(); + m_log.MainLogPrompt(); } } - public void RunCmd(string cmd, string[] cmdparams) + public override void RunCmd(string cmd, string[] cmdparams) { + base.RunCmd(cmd, cmdparams); + switch (cmd) { case "quit": @@ -121,14 +122,10 @@ namespace OpenSim.Grid.InventoryServer m_inventoryService.CreateUsersInventory(LLUUID.Random().UUID); break; case "shutdown": - m_console.Close(); + m_log.Close(); Environment.Exit(0); break; } } - - public void Show(string ShowWhat) - { - } } -} \ No newline at end of file +} diff --git a/OpenSim/Grid/MessagingServer/Main.cs b/OpenSim/Grid/MessagingServer/Main.cs index a7c3a2a..3d5ceb4 100644 --- a/OpenSim/Grid/MessagingServer/Main.cs +++ b/OpenSim/Grid/MessagingServer/Main.cs @@ -39,14 +39,13 @@ namespace OpenSim.Grid.MessagingServer { /// /// - public class OpenMessage_Main : conscmd_callback + public class OpenMessage_Main : BaseOpenSimServer, conscmd_callback { private MessageServerConfig Cfg; //public UserManager m_userManager; //public UserLoginService m_loginService; - - private LogBase m_console; + private LLUUID m_lastCreatedUser = LLUUID.Random(); [STAThread] @@ -66,18 +65,18 @@ namespace OpenSim.Grid.MessagingServer { Directory.CreateDirectory(Util.logDir()); } - m_console = + m_log = new LogBase((Path.Combine(Util.logDir(), "opengrid-messagingserver-console.log")), "OpenMessage", this, true); - MainLog.Instance = m_console; + MainLog.Instance = m_log; } private void Work() { - m_console.Notice("Enter help for a list of commands\n"); + m_log.Notice("Enter help for a list of commands\n"); while (true) { - m_console.MainLogPrompt(); + m_log.MainLogPrompt(); } } @@ -105,7 +104,7 @@ namespace OpenSim.Grid.MessagingServer //new RestStreamHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod)); httpServer.Start(); - m_console.Status("SERVER", "Messageserver 0.4 - Startup complete"); + m_log.Status("SERVER", "Messageserver 0.4 - Startup complete"); } @@ -121,7 +120,7 @@ namespace OpenSim.Grid.MessagingServer //m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY); } catch (Exception ex) { - m_console.Error("SERVER", "Error creating user: {0}", ex.ToString()); + m_log.Error("SERVER", "Error creating user: {0}", ex.ToString()); } try @@ -131,23 +130,25 @@ namespace OpenSim.Grid.MessagingServer } catch (Exception ex) { - m_console.Error("SERVER", "Error creating inventory for user: {0}", ex.ToString()); + m_log.Error("SERVER", "Error creating inventory for user: {0}", ex.ToString()); } // m_lastCreatedUser = userID; break; } } - public void RunCmd(string cmd, string[] cmdparams) + public override void RunCmd(string cmd, string[] cmdparams) { + base.RunCmd(cmd, cmdparams); + switch (cmd) { case "help": - m_console.Notice("shutdown - shutdown the message server (USE CAUTION!)"); + m_log.Notice("shutdown - shutdown the message server (USE CAUTION!)"); break; case "shutdown": - m_console.Close(); + m_log.Close(); Environment.Exit(0); break; } diff --git a/OpenSim/Grid/ScriptServer/ScriptServerMain.cs b/OpenSim/Grid/ScriptServer/ScriptServerMain.cs index 5757be4..421467d 100644 --- a/OpenSim/Grid/ScriptServer/ScriptServerMain.cs +++ b/OpenSim/Grid/ScriptServer/ScriptServerMain.cs @@ -31,20 +31,20 @@ using libsecondlife; using Nini.Config; using OpenSim.Framework; using OpenSim.Framework.Console; +using OpenSim.Framework.Servers; using OpenSim.Grid.ScriptServer.ScriptServer; using OpenSim.Region.ScriptEngine.Common; using OpenSim.Region.ScriptEngine.Common.TRPC; namespace OpenSim.Grid.ScriptServer { - public class ScriptServerMain : conscmd_callback + public class ScriptServerMain : BaseOpenSimServer, conscmd_callback { // // Root object. Creates objects used. // private int listenPort = 8010; private readonly string m_logFilename = ("scriptserver.log"); - private LogBase m_log; // TEMP public static ScriptServerInterfaces.ScriptEngine Engine; @@ -111,13 +111,5 @@ namespace OpenSim.Grid.ScriptServer return new LogBase((Path.Combine(Util.logDir(), m_logFilename)), "ScriptServer", this, true); } - - public void RunCmd(string command, string[] cmdparams) - { - } - - public void Show(string ShowWhat) - { - } } -} \ No newline at end of file +} diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs index 20828ba..32cefc1 100644 --- a/OpenSim/Grid/UserServer/Main.cs +++ b/OpenSim/Grid/UserServer/Main.cs @@ -40,7 +40,7 @@ namespace OpenSim.Grid.UserServer { /// /// - public class OpenUser_Main : conscmd_callback + public class OpenUser_Main : BaseOpenSimServer, conscmd_callback { private UserConfig Cfg; @@ -48,7 +48,6 @@ namespace OpenSim.Grid.UserServer public UserLoginService m_loginService; public MessageServersConnector m_messagesService; - private LogBase m_console; private LLUUID m_lastCreatedUser = LLUUID.Random(); [STAThread] @@ -68,18 +67,18 @@ namespace OpenSim.Grid.UserServer { Directory.CreateDirectory(Util.logDir()); } - m_console = + m_log = new LogBase((Path.Combine(Util.logDir(), "opengrid-userserver-console.log")), "OpenUser", this, true); - MainLog.Instance = m_console; + MainLog.Instance = m_log; } private void Work() { - m_console.Notice("Enter help for a list of commands\n"); + m_log.Notice("Enter help for a list of commands\n"); while (true) { - m_console.MainLogPrompt(); + m_log.MainLogPrompt(); } } @@ -129,7 +128,7 @@ namespace OpenSim.Grid.UserServer new RestStreamHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod)); httpServer.Start(); - m_console.Status("SERVER", "Userserver 0.4 - Startup complete"); + m_log.Status("SERVER", "Userserver 0.4 - Startup complete"); } @@ -144,11 +143,11 @@ namespace OpenSim.Grid.UserServer uint regX = 1000; uint regY = 1000; - tempfirstname = m_console.CmdPrompt("First name"); - templastname = m_console.CmdPrompt("Last name"); - tempMD5Passwd = m_console.PasswdPrompt("Password"); - regX = Convert.ToUInt32(m_console.CmdPrompt("Start Region X")); - regY = Convert.ToUInt32(m_console.CmdPrompt("Start Region Y")); + tempfirstname = m_log.CmdPrompt("First name"); + templastname = m_log.CmdPrompt("Last name"); + tempMD5Passwd = m_log.PasswdPrompt("Password"); + regX = Convert.ToUInt32(m_log.CmdPrompt("Start Region X")); + regY = Convert.ToUInt32(m_log.CmdPrompt("Start Region Y")); tempMD5Passwd = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + String.Empty); @@ -159,7 +158,7 @@ namespace OpenSim.Grid.UserServer m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY); } catch (Exception ex) { - m_console.Error("SERVER", "Error creating user: {0}", ex.ToString()); + m_log.Error("SERVER", "Error creating user: {0}", ex.ToString()); } try @@ -169,21 +168,23 @@ namespace OpenSim.Grid.UserServer } catch (Exception ex) { - m_console.Error("SERVER", "Error creating inventory for user: {0}", ex.ToString()); + m_log.Error("SERVER", "Error creating inventory for user: {0}", ex.ToString()); } m_lastCreatedUser = userID; break; } } - public void RunCmd(string cmd, string[] cmdparams) + public override void RunCmd(string cmd, string[] cmdparams) { + base.RunCmd(cmd, cmdparams); + switch (cmd) { case "help": - m_console.Notice("create user - create a new user"); - m_console.Notice("stats - statistical information for this server"); - m_console.Notice("shutdown - shutdown the grid (USE CAUTION!)"); + m_log.Notice("create user - create a new user"); + m_log.Notice("stats - statistical information for this server"); + m_log.Notice("shutdown - shutdown the grid (USE CAUTION!)"); break; case "create": @@ -192,7 +193,7 @@ namespace OpenSim.Grid.UserServer case "shutdown": m_loginService.OnUserLoggedInAtLocation -= NotifyMessageServersUserLoggedInToLocation; - m_console.Close(); + m_log.Close(); Environment.Exit(0); break; @@ -246,9 +247,5 @@ namespace OpenSim.Grid.UserServer } }*/ - - public void Show(string ShowWhat) - { - } } } -- cgit v1.1