* 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
ThreadPoolClientBranch
Justin Clarke Casey 2008-02-04 18:52:24 +00:00
parent 5db5630ec9
commit baefa05b57
9 changed files with 201 additions and 189 deletions

View File

@ -28,16 +28,59 @@
using System; using System;
using OpenSim.Framework.Console;
namespace OpenSim.Framework.Servers namespace OpenSim.Framework.Servers
{ {
/// <summary> /// <summary>
/// Common base for the main OpenSimServers (user, grid, inventory, region, etc) /// Common base for the main OpenSimServers (user, grid, inventory, region, etc)
/// XXX Not yet implemented, may not grow up for some time
/// </summary> /// </summary>
public class BaseOpenSimServer public abstract class BaseOpenSimServer
{ {
protected LogBase m_log;
protected DateTime m_startuptime;
public BaseOpenSimServer() public BaseOpenSimServer()
{ {
m_startuptime = DateTime.Now;
}
/// <summary>
/// Runs commands issued by the server console from the operator
/// </summary>
/// <param name="command">The first argument of the parameter (the command)</param>
/// <param name="cmdparams">Additional arguments passed to the command</param>
public virtual void RunCmd(string command, string[] cmdparams)
{
switch (command)
{
case "help":
m_log.Notice("show uptime - show server startup and uptime.");
break;
case "show":
if (cmdparams.Length > 0)
{
Show(cmdparams[0]);
}
break;
}
}
/// <summary>
/// Outputs to the console information about the region
/// </summary>
/// <param name="ShowWhat">What information to display (valid arguments are "uptime", "users")</param>
public virtual void Show(string ShowWhat)
{
switch (ShowWhat)
{
case "uptime":
m_log.Notice("Server has been running since " + m_startuptime.ToString());
m_log.Notice("That is " + (DateTime.Now - m_startuptime).ToString());
break;
}
} }
} }
} }

View File

@ -41,14 +41,12 @@ namespace OpenSim.Grid.AssetServer
/// <summary> /// <summary>
/// An asset server /// An asset server
/// </summary> /// </summary>
public class OpenAsset_Main : conscmd_callback public class OpenAsset_Main : BaseOpenSimServer, conscmd_callback
{ {
public AssetConfig m_config; public AssetConfig m_config;
public static OpenAsset_Main assetserver; public static OpenAsset_Main assetserver;
private LogBase m_console;
// Temporarily hardcoded - should be a plugin // Temporarily hardcoded - should be a plugin
protected IAssetLoader assetLoader = new AssetLoaderFileSystem(); protected IAssetLoader assetLoader = new AssetLoaderFileSystem();
@ -67,11 +65,11 @@ namespace OpenSim.Grid.AssetServer
private void Work() 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) while (true)
{ {
m_console.MainLogPrompt(); m_log.MainLogPrompt();
} }
} }
@ -81,22 +79,28 @@ namespace OpenSim.Grid.AssetServer
{ {
Directory.CreateDirectory(Util.logDir()); Directory.CreateDirectory(Util.logDir());
} }
m_console =
new LogBase((Path.Combine(Util.logDir(), "opengrid-AssetServer-console.log")), "OpenAsset", this, true); m_log =
MainLog.Instance = m_console; new LogBase(
(Path.Combine(Util.logDir(), "opengrid-AssetServer-console.log")),
"OpenAsset",
this,
true);
MainLog.Instance = m_log;
} }
public void Startup() public void Startup()
{ {
m_config = new AssetConfig("ASSET SERVER", (Path.Combine(Util.configDir(), "AssetServer_Config.xml"))); 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); setupDB(m_config);
m_console.Verbose("ASSET", "Loading default asset set.."); m_log.Verbose("ASSET", "Loading default asset set..");
LoadDefaultAssets(); LoadDefaultAssets();
m_console.Verbose("ASSET", "Starting HTTP process"); m_log.Verbose("ASSET", "Starting HTTP process");
BaseHttpServer httpServer = new BaseHttpServer(m_config.HttpPort); BaseHttpServer httpServer = new BaseHttpServer(m_config.HttpPort);
StatsManager.StartCollectingAssetStats(); StatsManager.StartCollectingAssetStats();
@ -170,30 +174,28 @@ namespace OpenSim.Grid.AssetServer
m_assetProvider.CreateAsset(asset); 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) switch (cmd)
{ {
case "help": case "help":
m_console.Notice( m_log.Notice(
@"shutdown - shutdown this asset server (USE CAUTION!) @"shutdown - shutdown this asset server (USE CAUTION!)
stats - statistical information for this server"); stats - statistical information for this server");
break; break;
case "stats": case "stats":
m_console.Notice("STATS", Environment.NewLine + StatsManager.AssetStats.Report()); m_log.Notice("STATS", Environment.NewLine + StatsManager.AssetStats.Report());
break; break;
case "shutdown": case "shutdown":
m_console.Close(); m_log.Close();
Environment.Exit(0); Environment.Exit(0);
break; break;
} }
} }
public void Show(string ShowWhat)
{
}
} }
} }

View File

@ -37,7 +37,7 @@ namespace OpenSim.Grid.GridServer
{ {
/// <summary> /// <summary>
/// </summary> /// </summary>
public class OpenGrid_Main : conscmd_callback public class OpenGrid_Main : BaseOpenSimServer, conscmd_callback
{ {
public GridConfig Cfg; public GridConfig Cfg;
@ -51,8 +51,6 @@ namespace OpenSim.Grid.GridServer
private GridManager m_gridManager; private GridManager m_gridManager;
private LogBase m_console;
[STAThread] [STAThread]
public static void Main(string[] args) public static void Main(string[] args)
{ {
@ -70,11 +68,11 @@ namespace OpenSim.Grid.GridServer
private void Work() 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) while (true)
{ {
m_console.MainLogPrompt(); m_log.MainLogPrompt();
} }
} }
@ -84,9 +82,9 @@ namespace OpenSim.Grid.GridServer
{ {
Directory.CreateDirectory(Util.logDir()); Directory.CreateDirectory(Util.logDir());
} }
m_console = m_log =
new LogBase((Path.Combine(Util.logDir(), "opengrid-gridserver-console.log")), "OpenGrid", this, true); 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) public void managercallback(string cmd)
@ -106,12 +104,12 @@ namespace OpenSim.Grid.GridServer
//Yeah srsly, that's it. //Yeah srsly, that's it.
if (setuponly) Environment.Exit(0); 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 = new GridManager();
m_gridManager.AddPlugin(Cfg.DatabaseProvider); // Made of win m_gridManager.AddPlugin(Cfg.DatabaseProvider); // Made of win
m_gridManager.config = Cfg; m_gridManager.config = Cfg;
m_console.Verbose("GRID", "Starting HTTP process"); m_log.Verbose("GRID", "Starting HTTP process");
BaseHttpServer httpServer = new BaseHttpServer(Cfg.HttpPort); BaseHttpServer httpServer = new BaseHttpServer(Cfg.HttpPort);
//GridManagementAgent GridManagerAgent = new GridManagementAgent(httpServer, "gridserver", Cfg.SimSendKey, Cfg.SimRecvKey, managercallback); //GridManagementAgent GridManagerAgent = new GridManagementAgent(httpServer, "gridserver", Cfg.SimSendKey, Cfg.SimRecvKey, managercallback);
@ -137,7 +135,7 @@ namespace OpenSim.Grid.GridServer
httpServer.Start(); 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. Timer simCheckTimer = new Timer(3600000*3); // 3 Hours between updates.
simCheckTimer.Elapsed += new ElapsedEventHandler(CheckSims); 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) switch (cmd)
{ {
case "help": case "help":
m_console.Notice("shutdown - shutdown the grid (USE CAUTION!)"); m_log.Notice("shutdown - shutdown the grid (USE CAUTION!)");
break; break;
case "shutdown": case "shutdown":
m_console.Close(); m_log.Close();
Environment.Exit(0); Environment.Exit(0);
break; break;
} }
} }
public void Show(string ShowWhat)
{
}
/*private void ConfigDB(IGenericConfig configData) /*private void ConfigDB(IGenericConfig configData)
{ {
try try

View File

@ -36,9 +36,8 @@ using OpenSim.Framework.Servers;
namespace OpenSim.Grid.InventoryServer 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 InventoryManager m_inventoryManager;
private InventoryConfig m_config; private InventoryConfig m_config;
private GridInventoryService m_inventoryService; private GridInventoryService m_inventoryService;
@ -56,8 +55,8 @@ namespace OpenSim.Grid.InventoryServer
public OpenInventory_Main() public OpenInventory_Main()
{ {
m_console = new LogBase("opengrid-inventory-console.log", LogName, this, true); m_log = new LogBase("opengrid-inventory-console.log", LogName, this, true);
MainLog.Instance = m_console; MainLog.Instance = m_log;
} }
public void Startup() public void Startup()
@ -104,16 +103,18 @@ namespace OpenSim.Grid.InventoryServer
private void Work() 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) 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) switch (cmd)
{ {
case "quit": case "quit":
@ -121,14 +122,10 @@ namespace OpenSim.Grid.InventoryServer
m_inventoryService.CreateUsersInventory(LLUUID.Random().UUID); m_inventoryService.CreateUsersInventory(LLUUID.Random().UUID);
break; break;
case "shutdown": case "shutdown":
m_console.Close(); m_log.Close();
Environment.Exit(0); Environment.Exit(0);
break; break;
} }
} }
public void Show(string ShowWhat)
{
}
} }
} }

View File

@ -39,14 +39,13 @@ namespace OpenSim.Grid.MessagingServer
{ {
/// <summary> /// <summary>
/// </summary> /// </summary>
public class OpenMessage_Main : conscmd_callback public class OpenMessage_Main : BaseOpenSimServer, conscmd_callback
{ {
private MessageServerConfig Cfg; private MessageServerConfig Cfg;
//public UserManager m_userManager; //public UserManager m_userManager;
//public UserLoginService m_loginService; //public UserLoginService m_loginService;
private LogBase m_console;
private LLUUID m_lastCreatedUser = LLUUID.Random(); private LLUUID m_lastCreatedUser = LLUUID.Random();
[STAThread] [STAThread]
@ -66,18 +65,18 @@ namespace OpenSim.Grid.MessagingServer
{ {
Directory.CreateDirectory(Util.logDir()); Directory.CreateDirectory(Util.logDir());
} }
m_console = m_log =
new LogBase((Path.Combine(Util.logDir(), "opengrid-messagingserver-console.log")), "OpenMessage", this, true); new LogBase((Path.Combine(Util.logDir(), "opengrid-messagingserver-console.log")), "OpenMessage", this, true);
MainLog.Instance = m_console; MainLog.Instance = m_log;
} }
private void Work() 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) while (true)
{ {
m_console.MainLogPrompt(); m_log.MainLogPrompt();
} }
} }
@ -105,7 +104,7 @@ namespace OpenSim.Grid.MessagingServer
//new RestStreamHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod)); //new RestStreamHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod));
httpServer.Start(); 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); //m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY);
} catch (Exception ex) } catch (Exception ex)
{ {
m_console.Error("SERVER", "Error creating user: {0}", ex.ToString()); m_log.Error("SERVER", "Error creating user: {0}", ex.ToString());
} }
try try
@ -131,23 +130,25 @@ namespace OpenSim.Grid.MessagingServer
} }
catch (Exception ex) 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; // m_lastCreatedUser = userID;
break; break;
} }
} }
public void RunCmd(string cmd, string[] cmdparams) public override void RunCmd(string cmd, string[] cmdparams)
{ {
base.RunCmd(cmd, cmdparams);
switch (cmd) switch (cmd)
{ {
case "help": case "help":
m_console.Notice("shutdown - shutdown the message server (USE CAUTION!)"); m_log.Notice("shutdown - shutdown the message server (USE CAUTION!)");
break; break;
case "shutdown": case "shutdown":
m_console.Close(); m_log.Close();
Environment.Exit(0); Environment.Exit(0);
break; break;
} }

View File

@ -31,20 +31,20 @@ using libsecondlife;
using Nini.Config; using Nini.Config;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Console; using OpenSim.Framework.Console;
using OpenSim.Framework.Servers;
using OpenSim.Grid.ScriptServer.ScriptServer; using OpenSim.Grid.ScriptServer.ScriptServer;
using OpenSim.Region.ScriptEngine.Common; using OpenSim.Region.ScriptEngine.Common;
using OpenSim.Region.ScriptEngine.Common.TRPC; using OpenSim.Region.ScriptEngine.Common.TRPC;
namespace OpenSim.Grid.ScriptServer namespace OpenSim.Grid.ScriptServer
{ {
public class ScriptServerMain : conscmd_callback public class ScriptServerMain : BaseOpenSimServer, conscmd_callback
{ {
// //
// Root object. Creates objects used. // Root object. Creates objects used.
// //
private int listenPort = 8010; private int listenPort = 8010;
private readonly string m_logFilename = ("scriptserver.log"); private readonly string m_logFilename = ("scriptserver.log");
private LogBase m_log;
// TEMP // TEMP
public static ScriptServerInterfaces.ScriptEngine Engine; 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); return new LogBase((Path.Combine(Util.logDir(), m_logFilename)), "ScriptServer", this, true);
} }
public void RunCmd(string command, string[] cmdparams)
{
}
public void Show(string ShowWhat)
{
}
} }
} }

View File

@ -40,7 +40,7 @@ namespace OpenSim.Grid.UserServer
{ {
/// <summary> /// <summary>
/// </summary> /// </summary>
public class OpenUser_Main : conscmd_callback public class OpenUser_Main : BaseOpenSimServer, conscmd_callback
{ {
private UserConfig Cfg; private UserConfig Cfg;
@ -48,7 +48,6 @@ namespace OpenSim.Grid.UserServer
public UserLoginService m_loginService; public UserLoginService m_loginService;
public MessageServersConnector m_messagesService; public MessageServersConnector m_messagesService;
private LogBase m_console;
private LLUUID m_lastCreatedUser = LLUUID.Random(); private LLUUID m_lastCreatedUser = LLUUID.Random();
[STAThread] [STAThread]
@ -68,18 +67,18 @@ namespace OpenSim.Grid.UserServer
{ {
Directory.CreateDirectory(Util.logDir()); Directory.CreateDirectory(Util.logDir());
} }
m_console = m_log =
new LogBase((Path.Combine(Util.logDir(), "opengrid-userserver-console.log")), "OpenUser", this, true); new LogBase((Path.Combine(Util.logDir(), "opengrid-userserver-console.log")), "OpenUser", this, true);
MainLog.Instance = m_console; MainLog.Instance = m_log;
} }
private void Work() 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) while (true)
{ {
m_console.MainLogPrompt(); m_log.MainLogPrompt();
} }
} }
@ -129,7 +128,7 @@ namespace OpenSim.Grid.UserServer
new RestStreamHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod)); new RestStreamHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod));
httpServer.Start(); 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 regX = 1000;
uint regY = 1000; uint regY = 1000;
tempfirstname = m_console.CmdPrompt("First name"); tempfirstname = m_log.CmdPrompt("First name");
templastname = m_console.CmdPrompt("Last name"); templastname = m_log.CmdPrompt("Last name");
tempMD5Passwd = m_console.PasswdPrompt("Password"); tempMD5Passwd = m_log.PasswdPrompt("Password");
regX = Convert.ToUInt32(m_console.CmdPrompt("Start Region X")); regX = Convert.ToUInt32(m_log.CmdPrompt("Start Region X"));
regY = Convert.ToUInt32(m_console.CmdPrompt("Start Region Y")); regY = Convert.ToUInt32(m_log.CmdPrompt("Start Region Y"));
tempMD5Passwd = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + String.Empty); tempMD5Passwd = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + String.Empty);
@ -159,7 +158,7 @@ namespace OpenSim.Grid.UserServer
m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY); m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY);
} catch (Exception ex) } catch (Exception ex)
{ {
m_console.Error("SERVER", "Error creating user: {0}", ex.ToString()); m_log.Error("SERVER", "Error creating user: {0}", ex.ToString());
} }
try try
@ -169,21 +168,23 @@ namespace OpenSim.Grid.UserServer
} }
catch (Exception ex) 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; m_lastCreatedUser = userID;
break; break;
} }
} }
public void RunCmd(string cmd, string[] cmdparams) public override void RunCmd(string cmd, string[] cmdparams)
{ {
base.RunCmd(cmd, cmdparams);
switch (cmd) switch (cmd)
{ {
case "help": case "help":
m_console.Notice("create user - create a new user"); m_log.Notice("create user - create a new user");
m_console.Notice("stats - statistical information for this server"); m_log.Notice("stats - statistical information for this server");
m_console.Notice("shutdown - shutdown the grid (USE CAUTION!)"); m_log.Notice("shutdown - shutdown the grid (USE CAUTION!)");
break; break;
case "create": case "create":
@ -192,7 +193,7 @@ namespace OpenSim.Grid.UserServer
case "shutdown": case "shutdown":
m_loginService.OnUserLoggedInAtLocation -= NotifyMessageServersUserLoggedInToLocation; m_loginService.OnUserLoggedInAtLocation -= NotifyMessageServersUserLoggedInToLocation;
m_console.Close(); m_log.Close();
Environment.Exit(0); Environment.Exit(0);
break; break;
@ -246,9 +247,5 @@ namespace OpenSim.Grid.UserServer
} }
}*/ }*/
public void Show(string ShowWhat)
{
}
} }
} }

View File

@ -360,7 +360,7 @@ namespace OpenSim
m_moduleLoader = new ModuleLoader(m_log, m_config); m_moduleLoader = new ModuleLoader(m_log, m_config);
ExtensionNodeList nodes = AddinManager.GetExtensionNodes("/OpenSim/Startup"); ExtensionNodeList nodes = AddinManager.GetExtensionNodes("/OpenSim/Startup");
MainLog.Instance.Verbose("PLUGINS", "Loading {0} OpenSim application plugins", nodes.Count); m_log.Verbose("PLUGINS", "Loading {0} OpenSim application plugins", nodes.Count);
foreach (TypeExtensionNode node in nodes) foreach (TypeExtensionNode node in nodes)
{ {
@ -383,7 +383,7 @@ namespace OpenSim
} }
else else
{ {
MainLog.Instance.Verbose("STARTUP", "No startup command script specified. Moving on..."); m_log.Verbose("STARTUP", "No startup command script specified. Moving on...");
} }
// Start timer script (run a script every xx seconds) // Start timer script (run a script every xx seconds)
@ -396,7 +396,7 @@ namespace OpenSim
} }
// We are done with startup // We are done with startup
MainLog.Instance.Status("STARTUP", m_log.Status("STARTUP",
"Startup complete, serving " + m_udpServers.Count.ToString() + " region(s)"); "Startup complete, serving " + m_udpServers.Count.ToString() + " region(s)");
// When we return now we will be in a wait for input command loop. // When we return now we will be in a wait for input command loop.
@ -448,23 +448,23 @@ namespace OpenSim
UDPServer udpServer; UDPServer udpServer;
Scene scene = SetupScene(regionInfo, out udpServer, m_permissions); Scene scene = SetupScene(regionInfo, out udpServer, m_permissions);
MainLog.Instance.Verbose("MODULES", "Loading Region's modules"); m_log.Verbose("MODULES", "Loading Region's modules");
m_moduleLoader.PickupModules(scene, "."); m_moduleLoader.PickupModules(scene, ".");
//m_moduleLoader.PickupModules(scene, "ScriptEngines"); //m_moduleLoader.PickupModules(scene, "ScriptEngines");
//m_moduleLoader.LoadRegionModules(Path.Combine("ScriptEngines", m_scriptEngine), scene); //m_moduleLoader.LoadRegionModules(Path.Combine("ScriptEngines", m_scriptEngine), scene);
MainLog.Instance.Verbose("MODULES", "Loading scripting engine modules"); m_log.Verbose("MODULES", "Loading scripting engine modules");
foreach (string module in m_scriptEngine.Split(',')) foreach (string module in m_scriptEngine.Split(','))
{ {
string mod = module.Trim(" \t".ToCharArray()); // Clean up name string mod = module.Trim(" \t".ToCharArray()); // Clean up name
MainLog.Instance.Verbose("MODULES", "Loading scripting engine: " + mod); m_log.Verbose("MODULES", "Loading scripting engine: " + mod);
try try
{ {
m_moduleLoader.LoadRegionModules(Path.Combine("ScriptEngines", mod), scene); m_moduleLoader.LoadRegionModules(Path.Combine("ScriptEngines", mod), scene);
} }
catch (Exception ex) catch (Exception ex)
{ {
MainLog.Instance.Error("MODULES", "Failed to load script engine: " + ex.ToString()); m_log.Error("MODULES", "Failed to load script engine: " + ex.ToString());
} }
} }
@ -503,7 +503,7 @@ namespace OpenSim
SceneCommunicationService sceneGridService = new SceneCommunicationService(m_commsManager); SceneCommunicationService sceneGridService = new SceneCommunicationService(m_commsManager);
if (m_SendChildAgentTaskData) if (m_SendChildAgentTaskData)
{ {
MainLog.Instance.Error("WARNING", m_log.Error("WARNING",
"Send Child Agent Task Updates is enabled. This is for testing only."); "Send Child Agent Task Updates is enabled. This is for testing only.");
//Thread.Sleep(12000); //Thread.Sleep(12000);
} }
@ -516,7 +516,7 @@ namespace OpenSim
public void handleRestartRegion(RegionInfo whichRegion) public void handleRestartRegion(RegionInfo whichRegion)
{ {
MainLog.Instance.Error("MAIN", "Got restart signal from SceneManager"); m_log.Error("MAIN", "Got restart signal from SceneManager");
// Shutting down the UDP server // Shutting down the UDP server
bool foundUDPServer = false; bool foundUDPServer = false;
int UDPServerElement = 0; int UDPServerElement = 0;
@ -637,7 +637,7 @@ namespace OpenSim
/// <param name="fileName"></param> /// <param name="fileName"></param>
private void RunCommandScript(string fileName) private void RunCommandScript(string fileName)
{ {
MainLog.Instance.Verbose("COMMANDFILE", "Running " + fileName); m_log.Verbose("COMMANDFILE", "Running " + fileName);
if (File.Exists(fileName)) if (File.Exists(fileName))
{ {
StreamReader readFile = File.OpenText(fileName); StreamReader readFile = File.OpenText(fileName);
@ -646,14 +646,14 @@ namespace OpenSim
{ {
if (currentCommand != String.Empty) if (currentCommand != String.Empty)
{ {
MainLog.Instance.Verbose("COMMANDFILE", "Running '" + currentCommand + "'"); m_log.Verbose("COMMANDFILE", "Running '" + currentCommand + "'");
MainLog.Instance.MainLogRunCommand(currentCommand); m_log.MainLogRunCommand(currentCommand);
} }
} }
} }
else else
{ {
MainLog.Instance.Error("COMMANDFILE", "Command script missing. Can not run commands"); m_log.Error("COMMANDFILE", "Command script missing. Can not run commands");
} }
} }
@ -662,9 +662,9 @@ namespace OpenSim
/// </summary> /// </summary>
/// <param name="command">The first argument of the parameter (the command)</param> /// <param name="command">The first argument of the parameter (the command)</param>
/// <param name="cmdparams">Additional arguments passed to the command</param> /// <param name="cmdparams">Additional arguments passed to the command</param>
public void RunCmd(string command, string[] cmdparams) public override void RunCmd(string command, string[] cmdparams)
{ {
string result = String.Empty; base.RunCmd(command, cmdparams);
switch (command) switch (command)
{ {
@ -692,44 +692,36 @@ namespace OpenSim
break; break;
case "help": case "help":
m_log.Error("alert - send alert to a designated user or all users."); m_log.Notice("alert - send alert to a designated user or all users.");
m_log.Error(" alert [First] [Last] [Message] - send an alert to a user. Case sensitive."); m_log.Notice(" alert [First] [Last] [Message] - send an alert to a user. Case sensitive.");
m_log.Error(" alert general [Message] - send an alert to all users."); m_log.Notice(" alert general [Message] - send an alert to all users.");
m_log.Error("backup - trigger a simulator backup"); m_log.Notice("backup - trigger a simulator backup");
m_log.Error("create user - adds a new user"); m_log.Notice("create user - adds a new user");
m_log.Error("change-region [name] - sets the region that many of these commands affect."); m_log.Notice("change-region [name] - sets the region that many of these commands affect.");
m_log.Error("command-script [filename] - Execute command in a file."); m_log.Notice("command-script [filename] - Execute command in a file.");
m_log.Error("debug - debugging commands"); m_log.Notice("debug - debugging commands");
m_log.Error(" packet 0..255 - print incoming/outgoing packets (0=off)"); m_log.Notice(" packet 0..255 - print incoming/outgoing packets (0=off)");
m_log.Error("edit-scale [prim name] [x] [y] [z] - resize given prim"); m_log.Notice("edit-scale [prim name] [x] [y] [z] - resize given prim");
m_log.Error("export-map [filename] - save image of world map"); m_log.Notice("export-map [filename] - save image of world map");
m_log.Error("force-update - force an update of prims in the scene"); m_log.Notice("force-update - force an update of prims in the scene");
m_log.Error("load-xml [filename] - load prims from XML"); m_log.Notice("load-xml [filename] - load prims from XML");
m_log.Error("load-xml2 [filename] - load prims from XML using version 2 format"); m_log.Notice("load-xml2 [filename] - load prims from XML using version 2 format");
m_log.Error("permissions [true/false] - turn on/off permissions on the scene"); m_log.Notice("permissions [true/false] - turn on/off permissions on the scene");
m_log.Error("quit - equivalent to shutdown."); m_log.Notice("quit - equivalent to shutdown.");
m_log.Error("restart - disconnects all clients and restarts the sims in the instance."); m_log.Notice("restart - disconnects all clients and restarts the sims in the instance.");
m_log.Error("remove-region [name] - remove a region"); m_log.Notice("remove-region [name] - remove a region");
m_log.Error("save-xml [filename] - save prims to XML"); m_log.Notice("save-xml [filename] - save prims to XML");
m_log.Error("save-xml2 [filename] - save prims to XML using version 2 format"); m_log.Notice("save-xml2 [filename] - save prims to XML using version 2 format");
m_log.Error("script - manually trigger scripts? or script commands?"); m_log.Notice("script - manually trigger scripts? or script commands?");
m_log.Error("set-time [x] - set the current scene time phase"); m_log.Notice("set-time [x] - set the current scene time phase");
m_log.Error("show uptime - show simulator startup and uptime."); m_log.Notice("show users - show info about connected users.");
m_log.Error("show users - show info about connected users."); m_log.Notice("show modules - shows info aboutloaded modules.");
m_log.Error("show modules - shows info aboutloaded modules."); m_log.Notice("show stats - statistical information for this server not displayed in the client");
m_log.Error("show stats - statistical information for this server not displayed in the client"); m_log.Notice("shutdown - disconnect all clients and shutdown.");
m_log.Error("shutdown - disconnect all clients and shutdown."); m_log.Notice("config set section field value - set a config value");
m_log.Error("config set section field value - set a config value"); m_log.Notice("config get section field - get a config value");
m_log.Error("config get section field - get a config value"); m_log.Notice("config save - save OpenSim.ini");
m_log.Error("config save - save OpenSim.ini"); m_log.Notice("terrain help - show help for terrain commands.");
m_log.Error("terrain help - show help for terrain commands.");
break;
case "show":
if (cmdparams.Length > 0)
{
Show(cmdparams[0]);
}
break; break;
case "save-xml": case "save-xml":
@ -800,6 +792,8 @@ namespace OpenSim
break; break;
case "terrain": case "terrain":
string result = String.Empty;
if (!m_sceneManager.RunTerrainCmdOnCurrentScene(cmdparams, ref result)) if (!m_sceneManager.RunTerrainCmdOnCurrentScene(cmdparams, ref result))
{ {
m_log.Error(result); m_log.Error(result);
@ -873,18 +867,18 @@ namespace OpenSim
if (!m_sceneManager.TrySetCurrentScene(regionName)) if (!m_sceneManager.TrySetCurrentScene(regionName))
{ {
MainLog.Instance.Error("Couldn't set current region to: " + regionName); m_log.Error("Couldn't set current region to: " + regionName);
} }
} }
if (m_sceneManager.CurrentScene == null) if (m_sceneManager.CurrentScene == null)
{ {
MainLog.Instance.Verbose("CONSOLE", m_log.Notice("CONSOLE",
"Currently at Root level. To change region please use 'change-region <regioname>'"); "Currently at Root level. To change region please use 'change-region <regioname>'");
} }
else else
{ {
MainLog.Instance.Verbose("CONSOLE", m_log.Notice("CONSOLE",
"Current Region: " + m_sceneManager.CurrentScene.RegionInfo.RegionName + "Current Region: " + m_sceneManager.CurrentScene.RegionInfo.RegionName +
". To change region please use 'change-region <regioname>'"); ". To change region please use 'change-region <regioname>'");
} }
@ -911,8 +905,8 @@ namespace OpenSim
case "set": case "set":
if (cmdparams.Length < 4) if (cmdparams.Length < 4)
{ {
MainLog.Instance.Notice(n, "SYNTAX: " + n + " SET SECTION KEY VALUE"); m_log.Notice(n, "SYNTAX: " + n + " SET SECTION KEY VALUE");
MainLog.Instance.Notice(n, "EXAMPLE: " + n + " SET ScriptEngine.DotNetEngine NumberOfScriptThreads 5"); m_log.Notice(n, "EXAMPLE: " + n + " SET ScriptEngine.DotNetEngine NumberOfScriptThreads 5");
} }
else else
{ {
@ -923,7 +917,7 @@ namespace OpenSim
c.Set(cmdparams[2], _value); c.Set(cmdparams[2], _value);
m_config.Merge(c.ConfigSource); m_config.Merge(c.ConfigSource);
MainLog.Instance.Notice(n, m_log.Notice(n,
n + " " + n + " " + cmdparams[1] + " " + cmdparams[2] + " " + n + " " + n + " " + cmdparams[1] + " " + cmdparams[2] + " " +
_value); _value);
} }
@ -931,20 +925,20 @@ namespace OpenSim
case "get": case "get":
if (cmdparams.Length < 3) if (cmdparams.Length < 3)
{ {
MainLog.Instance.Notice(n, "SYNTAX: " + n + " GET SECTION KEY"); m_log.Notice(n, "SYNTAX: " + n + " GET SECTION KEY");
MainLog.Instance.Notice(n, "EXAMPLE: " + n + " GET ScriptEngine.DotNetEngine NumberOfScriptThreads"); m_log.Notice(n, "EXAMPLE: " + n + " GET ScriptEngine.DotNetEngine NumberOfScriptThreads");
} }
else else
{ {
IConfig c = DefaultConfig().Configs[cmdparams[1]]; IConfig c = DefaultConfig().Configs[cmdparams[1]];
if (c == null) if (c == null)
{ {
MainLog.Instance.Notice(n, "Section \"" + cmdparams[1] + "\" does not exist."); m_log.Notice(n, "Section \"" + cmdparams[1] + "\" does not exist.");
break; break;
} }
else else
{ {
MainLog.Instance.Notice(n, m_log.Notice(n,
n + " GET " + cmdparams[1] + " " + cmdparams[2] + ": " + n + " GET " + cmdparams[1] + " " + cmdparams[2] + ": " +
c.GetString(cmdparams[2])); c.GetString(cmdparams[2]));
} }
@ -952,18 +946,20 @@ namespace OpenSim
break; break;
case "save": case "save":
MainLog.Instance.Notice(n, "Saving configuration file: " + Application.iniFilePath); m_log.Notice(n, "Saving configuration file: " + Application.iniFilePath);
m_config.Save(Application.iniFilePath); m_config.Save(Application.iniFilePath);
break; break;
} }
} }
else
{
}
break; break;
/*
* Temporarily disabled but it would be good to have this - needs to be levered
* in to BaseOpenSimServer (which requires a RunCmd method restrcuture probably)
default: default:
m_log.Error("Unknown command"); m_log.Error("Unknown command");
break; break;
*/
} }
} }
@ -993,18 +989,13 @@ namespace OpenSim
} }
} }
/// <summary> // see BaseOpenSimServer
/// Outputs to the console information about the region
/// </summary>
/// <param name="ShowWhat">What information to display (valid arguments are "uptime", "users")</param>
public void Show(string ShowWhat) public void Show(string ShowWhat)
{ {
base.Show(ShowWhat);
switch (ShowWhat) switch (ShowWhat)
{ {
case "uptime":
m_log.Error("OpenSim has been running since " + m_startuptime.ToString());
m_log.Error("That is " + (DateTime.Now - m_startuptime).ToString());
break;
case "users": case "users":
m_log.Error( m_log.Error(
String.Format("{0,-16}{1,-16}{2,-37}{3,-16}{4,-22}{5,-16}", "Firstname", "Lastname", String.Format("{0,-16}{1,-16}{2,-37}{3,-16}{4,-22}{5,-16}", "Firstname", "Lastname",

View File

@ -40,17 +40,15 @@ using OpenSim.Region.Physics.Manager;
namespace OpenSim.Region.ClientStack namespace OpenSim.Region.ClientStack
{ {
public abstract class RegionApplicationBase public abstract class RegionApplicationBase : BaseOpenSimServer
{ {
protected AssetCache m_assetCache; protected AssetCache m_assetCache;
protected Dictionary<EndPoint, uint> m_clientCircuits = new Dictionary<EndPoint, uint>(); protected Dictionary<EndPoint, uint> m_clientCircuits = new Dictionary<EndPoint, uint>();
protected DateTime m_startuptime;
protected NetworkServersInfo m_networkServersInfo; protected NetworkServersInfo m_networkServersInfo;
protected BaseHttpServer m_httpServer; protected BaseHttpServer m_httpServer;
protected uint m_httpServerPort; protected uint m_httpServerPort;
protected LogBase m_log;
protected CommunicationsManager m_commsManager; protected CommunicationsManager m_commsManager;
protected SceneManager m_sceneManager = new SceneManager(); protected SceneManager m_sceneManager = new SceneManager();
@ -67,11 +65,6 @@ namespace OpenSim.Region.ClientStack
get { return m_sceneManager; } get { return m_sceneManager; }
} }
public RegionApplicationBase()
{
m_startuptime = DateTime.Now;
}
public virtual void StartUp() public virtual void StartUp()
{ {
ClientView.TerrainManager = new TerrainManager(new SecondLife()); ClientView.TerrainManager = new TerrainManager(new SecondLife());