From 646f8bf186e89f85feae5ff982252e908ea5cda5 Mon Sep 17 00:00:00 2001 From: gareth Date: Thu, 8 Mar 2007 00:50:57 +0000 Subject: [PATCH] Began to create grid server framework --- ServerConsole/ServerConsole.cs | 5 ++ ServerConsole/default.build | 3 +- common/src/OGS-Console.cs | 83 ++++++++++-------------------- common/src/VersionInfo.cs.template | 37 +++++++++++++ gridserver/default.build | 51 ++++++++++++++++++ gridserver/src/Main.cs | 63 +++++++++++++++++++++++ ogs.build | 38 ++++++++++++++ 7 files changed, 222 insertions(+), 58 deletions(-) create mode 100644 common/src/VersionInfo.cs.template create mode 100644 gridserver/default.build create mode 100644 gridserver/src/Main.cs create mode 100644 ogs.build diff --git a/ServerConsole/ServerConsole.cs b/ServerConsole/ServerConsole.cs index 93c8114a85..d1bbf11c30 100644 --- a/ServerConsole/ServerConsole.cs +++ b/ServerConsole/ServerConsole.cs @@ -50,6 +50,11 @@ namespace ServerConsole } } + public abstract class conscmd_callback { + public abstract void RunCmd(string cmd, string[] cmdparams); + public abstract void Show(string ShowWhat); + } + public abstract class ConsoleBase { diff --git a/ServerConsole/default.build b/ServerConsole/default.build index 0f5998a031..64a4f04ed7 100644 --- a/ServerConsole/default.build +++ b/ServerConsole/default.build @@ -1,6 +1,5 @@ - - nant buildfile for OpenSim + diff --git a/common/src/OGS-Console.cs b/common/src/OGS-Console.cs index 7d8563f597..a7adf1486e 100644 --- a/common/src/OGS-Console.cs +++ b/common/src/OGS-Console.cs @@ -31,11 +31,9 @@ using System.Collections.Generic; using System.Threading; using System.IO; using System.Net; -using libsecondlife; -using libsecondlife.Packets; using ServerConsole; -namespace OpenSim +namespace OpenGridServices { /// /// Description of ServerConsole. @@ -45,32 +43,34 @@ namespace OpenSim private ConsoleType ConsType; StreamWriter Log; - + public conscmd_callback cmdparser; + public string componentname; // STUPID HACK ALERT!!!! STUPID HACK ALERT!!!!! // constype - the type of console to use (see enum ConsoleType) // sparam - depending on the console type: // TCP - the IP to bind to (127.0.0.1 if blank) // Local - param ignored - // SimChat - the AgentID of this sim's admin // and for the iparam: // TCP - the port to bind to // Local - param ignored - // SimChat - the chat channel to accept commands from - public MServerConsole(ConsoleType constype, string sparam, int iparam) { + // LogFile - duh + // componentname - which component of the OGS system? (user, asset etc) + + public MServerConsole(ConsoleType constype, string sparam, int iparam, string LogFile, string componentname) { ConsType = constype; + this.componentname = componentname; switch(constype) { case ConsoleType.Local: Console.WriteLine("ServerConsole.cs - creating new local console"); - Console.WriteLine("Logs will be saved to current directory in opensim-console.log"); - Log=File.AppendText("opensim-console.log"); + Console.WriteLine("Logs will be saved to current directory in " + LogFile); + Log=File.AppendText(LogFile); Log.WriteLine("========================================================================"); - //Log.WriteLine("OpenSim " + VersionInfo.Version + " Started at " + DateTime.Now.ToString()); + Log.WriteLine(componentname + VersionInfo.Version + " Started at " + DateTime.Now.ToString()); break; + case ConsoleType.TCP: break; - case ConsoleType.SimChat: - break; default: Console.WriteLine("ServerConsole.cs - what are you smoking? that isn't a valid console type!"); @@ -79,7 +79,7 @@ namespace OpenSim } public override void Close() { - Log.WriteLine("OpenSim shutdown at " + DateTime.Now.ToString()); + Log.WriteLine("Shutdown at " + DateTime.Now.ToString()); Log.Close(); } @@ -141,54 +141,25 @@ namespace OpenSim // Runs a command with a number of parameters public override Object RunCmd(string Cmd, string[] cmdparams) { - switch(Cmd) { - case "help": - this.WriteLine("show users - show info about connected users"); - this.WriteLine("shutdown - disconnect all clients and shutdown"); - break; - - case "show": - ShowCommands(cmdparams[0]); - break; - - case "shutdown": - OpenSim_Main.Shutdown(); - break; - } + cmdparser.RunCmd(Cmd, cmdparams); return null; } // Shows data about something public override void ShowCommands(string ShowWhat) { - switch(ShowWhat) { - case "uptime": - this.WriteLine("OpenSim has been running since " + OpenSim_Main.sim.startuptime.ToString()); - this.WriteLine("That is " + (DateTime.Now-OpenSim_Main.sim.startuptime).ToString()); - break; - case "users": - OpenSim.world.Avatar TempAv; - this.WriteLine(String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}","Firstname", "Lastname","Agent ID", "Session ID", "Circuit", "IP")); - foreach (libsecondlife.LLUUID UUID in OpenSim_Main.local_world.Entities.Keys) { - TempAv=(OpenSim.world.Avatar)OpenSim_Main.local_world.Entities[UUID]; - this.WriteLine(String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}",TempAv.firstname, TempAv.lastname,UUID, TempAv.ControllingClient.SessionID, TempAv.ControllingClient.CircuitCode, TempAv.ControllingClient.userEP.ToString())); - } - break; - } - } - - // Displays a prompt to the user and then runs the command they entered - public override void MainConsolePrompt() { - string[] tempstrarray; - string tempstr = this.CmdPrompt("OpenSim-" + OpenSim_Main.cfg.RegionHandle.ToString() + " # "); - tempstrarray = tempstr.Split(' '); - string cmd=tempstrarray[0]; - Array.Reverse(tempstrarray); - Array.Resize(ref tempstrarray,tempstrarray.Length-1); - Array.Reverse(tempstrarray); - string[] cmdparams=(string[])tempstrarray; - RunCmd(cmd,cmdparams); + cmdparser.Show(ShowWhat); } + + public override void MainConsolePrompt() { + string[] tempstrarray; + string tempstr = this.CmdPrompt(this.componentname + "# "); + tempstrarray = tempstr.Split(' '); + string cmd=tempstrarray[0]; + Array.Reverse(tempstrarray); + Array.Resize(ref tempstrarray,tempstrarray.Length-1); + Array.Reverse(tempstrarray); + string[] cmdparams=(string[])tempstrarray; + RunCmd(cmd,cmdparams); + } } } - - diff --git a/common/src/VersionInfo.cs.template b/common/src/VersionInfo.cs.template new file mode 100644 index 0000000000..8f73b4b357 --- /dev/null +++ b/common/src/VersionInfo.cs.template @@ -0,0 +1,37 @@ +/* +Copyright (c) OpenSim project, http://osgrid.org/ +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +using System; + +namespace OpenGridServices +{ + /// + /// + public class VersionInfo + { + public static string Version = "@@VERSION"; + } +} diff --git a/gridserver/default.build b/gridserver/default.build new file mode 100644 index 0000000000..1017319a09 --- /dev/null +++ b/gridserver/default.build @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gridserver/src/Main.cs b/gridserver/src/Main.cs new file mode 100644 index 0000000000..33733ea00e --- /dev/null +++ b/gridserver/src/Main.cs @@ -0,0 +1,63 @@ +/* +Copyright (c) OpenSim project, http://osgrid.org/ + + +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +using System; +using System.Text; +using ServerConsole; + +namespace OpenGridServices +{ + /// + /// + public class OpenGrid_Main + { + + public static OpenGrid_Main thegrid; + + [STAThread] + public static void Main( string[] args ) + { + Console.WriteLine("OpenGrid " + VersionInfo.Version + "\n"); + Console.WriteLine("Starting...\n"); + ServerConsole.MainConsole.Instance = new MServerConsole(ServerConsole.ConsoleBase.ConsoleType.Local, "", 0, "opengrid-console.log", "OpenGrid"); + + thegrid = new OpenGrid_Main(); + thegrid.Startup(); + + while(true) { + ServerConsole.MainConsole.Instance.MainConsolePrompt(); + } + } + + public void Startup() { + ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Looking for configuration"); + + } + } +} diff --git a/ogs.build b/ogs.build new file mode 100644 index 0000000000..303b1bfdb3 --- /dev/null +++ b/ogs.build @@ -0,0 +1,38 @@ + + + nant buildfile for OpenSim + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +