Compare commits

...

5 Commits

Author SHA1 Message Date
Justin Clark-Casey (justincc)
9fcf3f1a3f Make "config show/set/get/save" console commands available on all servers 2012-11-22 05:48:41 +00:00
Justin Clark-Casey (justincc)
8269d2b893 Factor out common pid file creation and removal code.
Log path at which pid file is created or reason for failure to create.
2012-11-22 05:14:43 +00:00
Justin Clark-Casey (justincc)
42e87a6582 Add "get log level" command - this returns the current server session console logging level.
This supersedes getting information by calling "set log level" without a 4th argument, which is confusing.
2012-11-22 04:57:45 +00:00
Justin Clark-Casey (justincc)
34ff96a119 Remove unused BaseOpenSimServer.ShowHelp() 2012-11-22 04:52:29 +00:00
Justin Clark-Casey (justincc)
4c4379b50f Make "set log level" command available across all servers 2012-11-22 04:50:09 +00:00
7 changed files with 262 additions and 301 deletions

View File

@@ -61,8 +61,6 @@ namespace OpenSim.Framework.Servers
/// server.
/// </summary>
private Timer m_periodicDiagnosticsTimer = new Timer(60 * 60 * 1000);
protected string m_pidFile = String.Empty;
/// <summary>
/// Random uuid for private data
@@ -102,10 +100,6 @@ namespace OpenSim.Framework.Servers
"shutdown",
"Quit the application", HandleQuit);
m_console.Commands.AddCommand("General", false, "set log level",
"set log level <level>",
"Set the console logging level", HandleLogLevel);
m_console.Commands.AddCommand("General", false, "show threads",
"show threads",
"Show thread status", HandleShow);
@@ -254,54 +248,6 @@ namespace OpenSim.Framework.Servers
Shutdown();
}
private void HandleLogLevel(string module, string[] cmd)
{
if (null == m_consoleAppender)
{
Notice("No appender named Console found (see the log4net config file for this executable)!");
return;
}
if (cmd.Length > 3)
{
string rawLevel = cmd[3];
ILoggerRepository repository = LogManager.GetRepository();
Level consoleLevel = repository.LevelMap[rawLevel];
if (consoleLevel != null)
m_consoleAppender.Threshold = consoleLevel;
else
Notice(
String.Format(
"{0} is not a valid logging level. Valid logging levels are ALL, DEBUG, INFO, WARN, ERROR, FATAL, OFF",
rawLevel));
}
Notice(String.Format("Console log level is {0}", m_consoleAppender.Threshold));
}
/// <summary>
/// Show help information
/// </summary>
/// <param name="helpArgs"></param>
protected virtual void ShowHelp(string[] helpArgs)
{
Notice("");
if (helpArgs.Length == 0)
{
Notice("set log level [level] - change the console logging level only. For example, off or debug.");
Notice("show info - show server information (e.g. startup path).");
Notice("show threads - list tracked threads");
Notice("show uptime - show server startup time and uptime.");
Notice("show version - show server version.");
Notice("");
return;
}
}
public override void HandleShow(string module, string[] cmd)
{
base.HandleShow(module, cmd);
@@ -345,23 +291,6 @@ namespace OpenSim.Framework.Servers
MainConsole.Instance.OutputFormat("ERROR - Thread with id {0} not found in managed threads", threadId);
}
protected void CreatePIDFile(string path)
{
try
{
string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString();
FileStream fs = File.Create(path);
Byte[] buf = Encoding.ASCII.GetBytes(pidstring);
fs.Write(buf, 0, buf.Length);
fs.Close();
m_pidFile = path;
}
catch (Exception)
{
}
}
public string osSecret {
// Secret uuid for the simulator
get { return m_osSecret; }
@@ -379,20 +308,5 @@ namespace OpenSim.Framework.Servers
return StatsManager.SimExtraStats.XReport((DateTime.Now - m_startuptime).ToString() , m_version);
}
}
protected void RemovePIDFile()
{
if (m_pidFile != String.Empty)
{
try
{
File.Delete(m_pidFile);
m_pidFile = String.Empty;
}
catch (Exception)
{
}
}
}
}
}
}

View File

@@ -44,6 +44,8 @@ namespace OpenSim.Framework.Servers
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public IConfigSource Config { get; protected set; }
/// <summary>
/// Console to be used for any command line output. Can be null, in which case there should be no output.
/// </summary>
@@ -55,6 +57,8 @@ namespace OpenSim.Framework.Servers
protected DateTime m_startuptime;
protected string m_startupDirectory = Environment.CurrentDirectory;
protected string m_pidFile = String.Empty;
/// <summary>
/// Server version information. Usually VersionInfo + information about git commit, operating system, etc.
/// </summary>
@@ -67,6 +71,45 @@ namespace OpenSim.Framework.Servers
EnhanceVersionInformation();
}
protected void CreatePIDFile(string path)
{
try
{
string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString();
using (FileStream fs = File.Create(path))
{
Byte[] buf = Encoding.ASCII.GetBytes(pidstring);
fs.Write(buf, 0, buf.Length);
}
m_pidFile = path;
m_log.InfoFormat("[SERVER BASE]: Created pid file {0}", m_pidFile);
}
catch (Exception e)
{
m_log.Warn(string.Format("[SERVER BASE]: Could not create PID file at {0} ", path), e);
}
}
protected void RemovePIDFile()
{
if (m_pidFile != String.Empty)
{
try
{
File.Delete(m_pidFile);
}
catch (Exception e)
{
m_log.Error(string.Format("[SERVER BASE]: Error whilst removing {0} ", m_pidFile), e);
}
m_pidFile = String.Empty;
}
}
public void RegisterCommonAppenders(IConfig startupConfig)
{
ILoggerRepository repository = LogManager.GetRepository();
@@ -109,7 +152,7 @@ namespace OpenSim.Framework.Servers
m_logFileAppender.ActivateOptions();
}
m_log.InfoFormat("[LOGGING]: Logging started to file {0}", m_logFileAppender.File);
m_log.InfoFormat("[SERVER BASE]: Logging started to file {0}", m_logFileAppender.File);
}
}
@@ -126,6 +169,38 @@ namespace OpenSim.Framework.Servers
m_console.Commands.AddCommand(
"General", false, "show uptime", "show uptime", "Show server uptime", HandleShow);
m_console.Commands.AddCommand(
"General", false, "get log level", "get log level", "Get the current console logging level",
(mod, cmd) => ShowLogLevel());
m_console.Commands.AddCommand(
"General", false, "set log level", "set log level <level>",
"Set the console logging level for this session.", HandleSetLogLevel);
m_console.Commands.AddCommand(
"General", false, "config set",
"config set <section> <key> <value>",
"Set a config option. In most cases this is not useful since changed parameters are not dynamically reloaded. Neither do changed parameters persist - you will have to change a config file manually and restart.", HandleConfig);
m_console.Commands.AddCommand(
"General", false, "config get",
"config get [<section>] [<key>]",
"Synonym for config show",
HandleConfig);
m_console.Commands.AddCommand(
"General", false, "config show",
"config show [<section>] [<key>]",
"Show config information",
"If neither section nor field are specified, then the whole current configuration is printed." + Environment.NewLine
+ "If a section is given but not a field, then all fields in that section are printed.",
HandleConfig);
m_console.Commands.AddCommand(
"General", false, "config save",
"config save <path>",
"Save current configuration to a file at the given path", HandleConfig);
}
public virtual void HandleShow(string module, string[] cmd)
@@ -148,6 +223,149 @@ namespace OpenSim.Framework.Servers
}
}
/// <summary>
/// Change and load configuration file data.
/// </summary>
/// <param name="module"></param>
/// <param name="cmd"></param>
private void HandleConfig(string module, string[] cmd)
{
List<string> args = new List<string>(cmd);
args.RemoveAt(0);
string[] cmdparams = args.ToArray();
if (cmdparams.Length > 0)
{
string firstParam = cmdparams[0].ToLower();
switch (firstParam)
{
case "set":
if (cmdparams.Length < 4)
{
Notice("Syntax: config set <section> <key> <value>");
Notice("Example: config set ScriptEngine.DotNetEngine NumberOfScriptThreads 5");
}
else
{
IConfig c;
IConfigSource source = new IniConfigSource();
c = source.AddConfig(cmdparams[1]);
if (c != null)
{
string _value = String.Join(" ", cmdparams, 3, cmdparams.Length - 3);
c.Set(cmdparams[2], _value);
Config.Merge(source);
Notice("In section [{0}], set {1} = {2}", c.Name, cmdparams[2], _value);
}
}
break;
case "get":
case "show":
if (cmdparams.Length == 1)
{
foreach (IConfig config in Config.Configs)
{
Notice("[{0}]", config.Name);
string[] keys = config.GetKeys();
foreach (string key in keys)
Notice(" {0} = {1}", key, config.GetString(key));
}
}
else if (cmdparams.Length == 2 || cmdparams.Length == 3)
{
IConfig config = Config.Configs[cmdparams[1]];
if (config == null)
{
Notice("Section \"{0}\" does not exist.",cmdparams[1]);
break;
}
else
{
if (cmdparams.Length == 2)
{
Notice("[{0}]", config.Name);
foreach (string key in config.GetKeys())
Notice(" {0} = {1}", key, config.GetString(key));
}
else
{
Notice(
"config get {0} {1} : {2}",
cmdparams[1], cmdparams[2], config.GetString(cmdparams[2]));
}
}
}
else
{
Notice("Syntax: config {0} [<section>] [<key>]", firstParam);
Notice("Example: config {0} ScriptEngine.DotNetEngine NumberOfScriptThreads", firstParam);
}
break;
case "save":
if (cmdparams.Length < 2)
{
Notice("Syntax: config save <path>");
return;
}
string path = cmdparams[1];
Notice("Saving configuration file: {0}", path);
if (Config is IniConfigSource)
{
IniConfigSource iniCon = (IniConfigSource)Config;
iniCon.Save(path);
}
else if (Config is XmlConfigSource)
{
XmlConfigSource xmlCon = (XmlConfigSource)Config;
xmlCon.Save(path);
}
break;
}
}
}
private void HandleSetLogLevel(string module, string[] cmd)
{
if (cmd.Length != 4)
{
Notice("Usage: set log level <level>");
return;
}
if (null == m_consoleAppender)
{
Notice("No appender named Console found (see the log4net config file for this executable)!");
return;
}
string rawLevel = cmd[3];
ILoggerRepository repository = LogManager.GetRepository();
Level consoleLevel = repository.LevelMap[rawLevel];
if (consoleLevel != null)
m_consoleAppender.Threshold = consoleLevel;
else
Notice(
"{0} is not a valid logging level. Valid logging levels are ALL, DEBUG, INFO, WARN, ERROR, FATAL, OFF",
rawLevel);
ShowLogLevel();
}
private void ShowLogLevel()
{
Notice(String.Format("Console log level is {0}", m_consoleAppender.Threshold));
}
/// <summary>
/// Return a report about the uptime of this server
/// </summary>
@@ -200,26 +418,26 @@ namespace OpenSim.Framework.Servers
}
else if (File.Exists(gitRefPointerPath))
{
// m_log.DebugFormat("[OPENSIM]: Found {0}", gitRefPointerPath);
// m_log.DebugFormat("[SERVER BASE]: Found {0}", gitRefPointerPath);
string rawPointer = "";
using (StreamReader pointerFile = File.OpenText(gitRefPointerPath))
rawPointer = pointerFile.ReadLine();
// m_log.DebugFormat("[OPENSIM]: rawPointer [{0}]", rawPointer);
// m_log.DebugFormat("[SERVER BASE]: rawPointer [{0}]", rawPointer);
Match m = Regex.Match(rawPointer, "^ref: (.+)$");
if (m.Success)
{
// m_log.DebugFormat("[OPENSIM]: Matched [{0}]", m.Groups[1].Value);
// m_log.DebugFormat("[SERVER BASE]: Matched [{0}]", m.Groups[1].Value);
string gitRef = m.Groups[1].Value;
string gitRefPath = gitDir + gitRef;
if (File.Exists(gitRefPath))
{
// m_log.DebugFormat("[OPENSIM]: Found gitRefPath [{0}]", gitRefPath);
// m_log.DebugFormat("[SERVER BASE]: Found gitRefPath [{0}]", gitRefPath);
using (StreamReader refFile = File.OpenText(gitRefPath))
{

View File

@@ -188,7 +188,6 @@ namespace OpenSim
// Make sure command line options take precedence
m_config.Source.Merge(argvSource);
IConfig enVars = m_config.Source.Configs["Environment"];
if( enVars != null )

View File

@@ -82,8 +82,8 @@ namespace OpenSim
{
base.ReadExtraConfigSettings();
IConfig startupConfig = m_config.Source.Configs["Startup"];
IConfig networkConfig = m_config.Source.Configs["Network"];
IConfig startupConfig = Config.Configs["Startup"];
IConfig networkConfig = Config.Configs["Network"];
int stpMaxThreads = 15;
@@ -148,7 +148,7 @@ namespace OpenSim
break;
case "rest":
m_console = new RemoteConsole("Region");
((RemoteConsole)m_console).ReadConfig(m_config.Source);
((RemoteConsole)m_console).ReadConfig(Config);
break;
default:
m_console = new LocalConsole("Region");
@@ -158,7 +158,7 @@ namespace OpenSim
MainConsole.Instance = m_console;
RegisterCommonAppenders(m_config.Source.Configs["Startup"]);
RegisterCommonAppenders(Config.Configs["Startup"]);
RegisterConsoleCommands();
base.StartupSpecific();
@@ -357,26 +357,6 @@ namespace OpenSim
"restart",
"Restart all sims in this instance", RunCommand);
m_console.Commands.AddCommand("General", false, "config set",
"config set <section> <key> <value>",
"Set a config option. In most cases this is not useful since changed parameters are not dynamically reloaded. Neither do changed parameters persist - you will have to change a config file manually and restart.", HandleConfig);
m_console.Commands.AddCommand("General", false, "config get",
"config get [<section>] [<key>]",
"Synonym for config show",
HandleConfig);
m_console.Commands.AddCommand("General", false, "config show",
"config show [<section>] [<key>]",
"Show config information",
"If neither section nor field are specified, then the whole current configuration is printed." + Environment.NewLine
+ "If a section is given but not a field, then all fields in that section are printed.",
HandleConfig);
m_console.Commands.AddCommand("General", false, "config save",
"config save <path>",
"Save current configuration to a file at the given path", HandleConfig);
m_console.Commands.AddCommand("General", false, "command-script",
"command-script <script>",
"Run a command script from file", RunCommand);
@@ -619,111 +599,9 @@ namespace OpenSim
bool changed = PopulateRegionEstateInfo(regInfo);
IScene scene;
CreateRegion(regInfo, true, out scene);
if (changed)
regInfo.EstateSettings.Save();
}
/// <summary>
/// Change and load configuration file data.
/// </summary>
/// <param name="module"></param>
/// <param name="cmd"></param>
private void HandleConfig(string module, string[] cmd)
{
List<string> args = new List<string>(cmd);
args.RemoveAt(0);
string[] cmdparams = args.ToArray();
if (cmdparams.Length > 0)
{
string firstParam = cmdparams[0].ToLower();
switch (firstParam)
{
case "set":
if (cmdparams.Length < 4)
{
Notice("Syntax: config set <section> <key> <value>");
Notice("Example: config set ScriptEngine.DotNetEngine NumberOfScriptThreads 5");
}
else
{
IConfig c;
IConfigSource source = new IniConfigSource();
c = source.AddConfig(cmdparams[1]);
if (c != null)
{
string _value = String.Join(" ", cmdparams, 3, cmdparams.Length - 3);
c.Set(cmdparams[2], _value);
m_config.Source.Merge(source);
Notice("In section [{0}], set {1} = {2}", c.Name, cmdparams[2], _value);
}
}
break;
case "get":
case "show":
if (cmdparams.Length == 1)
{
foreach (IConfig config in m_config.Source.Configs)
{
Notice("[{0}]", config.Name);
string[] keys = config.GetKeys();
foreach (string key in keys)
Notice(" {0} = {1}", key, config.GetString(key));
}
}
else if (cmdparams.Length == 2 || cmdparams.Length == 3)
{
IConfig config = m_config.Source.Configs[cmdparams[1]];
if (config == null)
{
Notice("Section \"{0}\" does not exist.",cmdparams[1]);
break;
}
else
{
if (cmdparams.Length == 2)
{
Notice("[{0}]", config.Name);
foreach (string key in config.GetKeys())
Notice(" {0} = {1}", key, config.GetString(key));
}
else
{
Notice(
"config get {0} {1} : {2}",
cmdparams[1], cmdparams[2], config.GetString(cmdparams[2]));
}
}
}
else
{
Notice("Syntax: config {0} [<section>] [<key>]", firstParam);
Notice("Example: config {0} ScriptEngine.DotNetEngine NumberOfScriptThreads", firstParam);
}
break;
case "save":
if (cmdparams.Length < 2)
{
Notice("Syntax: config save <path>");
return;
}
if (Application.iniFilePath == cmdparams[1])
{
Notice("Path can not be " + Application.iniFilePath);
return;
}
Notice("Saving configuration file: " + cmdparams[1]);
m_config.Save(cmdparams[1]);
break;
}
}
regInfo.EstateSettings.Save();
}
/// <summary>

View File

@@ -100,13 +100,7 @@ namespace OpenSim
/// <value>
/// The config information passed into the OpenSimulator region server.
/// </value>
public OpenSimConfigSource ConfigSource
{
get { return m_config; }
set { m_config = value; }
}
protected OpenSimConfigSource m_config;
public OpenSimConfigSource ConfigSource { get; private set; }
public List<IClientNetworkServer> ClientServers
{
@@ -146,13 +140,14 @@ namespace OpenSim
protected virtual void LoadConfigSettings(IConfigSource configSource)
{
m_configLoader = new ConfigurationLoader();
m_config = m_configLoader.LoadConfigSettings(configSource, envConfigSource, out m_configSettings, out m_networkServersInfo);
ConfigSource = m_configLoader.LoadConfigSettings(configSource, envConfigSource, out m_configSettings, out m_networkServersInfo);
Config = ConfigSource.Source;
ReadExtraConfigSettings();
}
protected virtual void ReadExtraConfigSettings()
{
IConfig networkConfig = m_config.Source.Configs["Network"];
IConfig networkConfig = Config.Configs["Network"];
if (networkConfig != null)
{
proxyUrl = networkConfig.GetString("proxy_url", "");
@@ -185,7 +180,7 @@ namespace OpenSim
/// </summary>
protected override void StartupSpecific()
{
IConfig startupConfig = m_config.Source.Configs["Startup"];
IConfig startupConfig = Config.Configs["Startup"];
if (startupConfig != null)
{
string pidFile = startupConfig.GetString("PIDFile", String.Empty);
@@ -196,7 +191,7 @@ namespace OpenSim
}
// Load the simulation data service
IConfig simDataConfig = m_config.Source.Configs["SimulationDataStore"];
IConfig simDataConfig = Config.Configs["SimulationDataStore"];
if (simDataConfig == null)
throw new Exception("Configuration file is missing the [SimulationDataStore] section. Have you copied OpenSim.ini.example to OpenSim.ini to reference config-include/ files?");
@@ -204,7 +199,7 @@ namespace OpenSim
if (String.IsNullOrEmpty(module))
throw new Exception("Configuration file is missing the LocalServiceModule parameter in the [SimulationDataStore] section.");
m_simulationDataService = ServerUtils.LoadPlugin<ISimulationDataService>(module, new object[] { m_config.Source });
m_simulationDataService = ServerUtils.LoadPlugin<ISimulationDataService>(module, new object[] { Config });
if (m_simulationDataService == null)
throw new Exception(
string.Format(
@@ -212,7 +207,7 @@ namespace OpenSim
module));
// Load the estate data service
IConfig estateDataConfig = m_config.Source.Configs["EstateDataStore"];
IConfig estateDataConfig = Config.Configs["EstateDataStore"];
if (estateDataConfig == null)
throw new Exception("Configuration file is missing the [EstateDataStore] section. Have you copied OpenSim.ini.example to OpenSim.ini to reference config-include/ files?");
@@ -220,7 +215,7 @@ namespace OpenSim
if (String.IsNullOrEmpty(module))
throw new Exception("Configuration file is missing the LocalServiceModule parameter in the [EstateDataStore] section");
m_estateDataService = ServerUtils.LoadPlugin<IEstateDataService>(module, new object[] { m_config.Source });
m_estateDataService = ServerUtils.LoadPlugin<IEstateDataService>(module, new object[] { Config });
if (m_estateDataService == null)
throw new Exception(
string.Format(
@@ -369,7 +364,7 @@ namespace OpenSim
}
IClientNetworkServer clientServer;
Scene scene = SetupScene(regionInfo, proxyOffset, m_config.Source, out clientServer);
Scene scene = SetupScene(regionInfo, proxyOffset, Config, out clientServer);
m_log.Info("[MODULES]: Loading Region's modules (old style)");
@@ -451,10 +446,10 @@ namespace OpenSim
string estateOwnerPassword = null;
string rawEstateOwnerUuid = null;
if (m_config.Source.Configs[ESTATE_SECTION_NAME] != null)
if (Config.Configs[ESTATE_SECTION_NAME] != null)
{
string defaultEstateOwnerName
= m_config.Source.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerName", "").Trim();
= Config.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerName", "").Trim();
string[] ownerNames = defaultEstateOwnerName.Split(' ');
if (ownerNames.Length >= 2)
@@ -464,9 +459,9 @@ namespace OpenSim
}
// Info to be used only on Standalone Mode
rawEstateOwnerUuid = m_config.Source.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerUUID", null);
estateOwnerEMail = m_config.Source.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerEMail", null);
estateOwnerPassword = m_config.Source.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerPassword", null);
rawEstateOwnerUuid = Config.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerUUID", null);
estateOwnerEMail = Config.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerEMail", null);
estateOwnerPassword = Config.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerPassword", null);
}
MainConsole.Instance.OutputFormat("Estate {0} has no owner set.", regionInfo.EstateSettings.EstateName);
@@ -713,7 +708,7 @@ namespace OpenSim
return new Scene(
regionInfo, circuitManager, sceneGridService,
simDataService, estateDataService, false,
m_config.Source, m_version);
Config, m_version);
}
protected void ShutdownClientServer(RegionInfo whichRegion)
@@ -754,7 +749,7 @@ namespace OpenSim
protected override PhysicsScene GetPhysicsScene(string osSceneIdentifier)
{
return GetPhysicsScene(
m_configSettings.PhysicsEngine, m_configSettings.MeshEngineName, m_config.Source, osSceneIdentifier);
m_configSettings.PhysicsEngine, m_configSettings.MeshEngineName, Config, osSceneIdentifier);
}
/// <summary>
@@ -991,9 +986,9 @@ namespace OpenSim
string defaultEstateName = null;
if (m_config.Source.Configs[ESTATE_SECTION_NAME] != null)
if (Config.Configs[ESTATE_SECTION_NAME] != null)
{
defaultEstateName = m_config.Source.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateName", null);
defaultEstateName = Config.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateName", null);
if (defaultEstateName != null)
{
@@ -1076,28 +1071,14 @@ namespace OpenSim
MainConsole.Instance.Output("Joining the estate failed. Please try again.");
}
}
}
}
return true; // need to update the database
}
return true; // need to update the database
}
}
public class OpenSimConfigSource
{
public IConfigSource Source;
public void Save(string path)
{
if (Source is IniConfigSource)
{
IniConfigSource iniCon = (IniConfigSource) Source;
iniCon.Save(path);
}
else if (Source is XmlConfigSource)
{
XmlConfigSource xmlCon = (XmlConfigSource) Source;
xmlCon.Save(path);
}
}
}
}
}

View File

@@ -52,7 +52,7 @@ namespace OpenSim.Server.Base
protected override void ReadConfig()
{
IConfig networkConfig = m_Config.Configs["Network"];
IConfig networkConfig = Config.Configs["Network"];
if (networkConfig == null)
{

View File

@@ -56,23 +56,10 @@ namespace OpenSim.Server.Base
//
protected string[] m_Arguments;
// Configuration
//
protected IConfigSource m_Config = null;
public IConfigSource Config
{
get { return m_Config; }
}
// Run flag
//
private bool m_Running = true;
// PID file
//
private string m_pidFile = String.Empty;
// Handle all the automagical stuff
//
public ServicesServerBase(string prompt, string[] args) : base()
@@ -122,11 +109,11 @@ namespace OpenSim.Server.Base
configUri.Scheme == Uri.UriSchemeHttp)
{
XmlReader r = XmlReader.Create(iniFile);
m_Config = new XmlConfigSource(r);
Config = new XmlConfigSource(r);
}
else
{
m_Config = new IniConfigSource(iniFile);
Config = new IniConfigSource(iniFile);
}
}
catch (Exception e)
@@ -138,13 +125,13 @@ namespace OpenSim.Server.Base
// Merge the configuration from the command line into the
// loaded file
//
m_Config.Merge(argvConfig);
Config.Merge(argvConfig);
// Refresh the startupConfig post merge
//
if (m_Config.Configs["Startup"] != null)
if (Config.Configs["Startup"] != null)
{
startupConfig = m_Config.Configs["Startup"];
startupConfig = Config.Configs["Startup"];
}
prompt = startupConfig.GetString("Prompt", prompt);
@@ -240,8 +227,8 @@ namespace OpenSim.Server.Base
}
}
if (m_pidFile != String.Empty)
File.Delete(m_pidFile);
RemovePIDFile();
return 0;
}
@@ -249,6 +236,7 @@ namespace OpenSim.Server.Base
{
m_Running = false;
m_log.Info("[CONSOLE] Quitting");
}
protected virtual void HandleScript(string module, string[] parms)
@@ -285,7 +273,6 @@ namespace OpenSim.Server.Base
}
}
protected virtual void ReadConfig()
{
}
@@ -293,21 +280,5 @@ namespace OpenSim.Server.Base
protected virtual void Initialise()
{
}
protected void CreatePIDFile(string path)
{
try
{
string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString();
FileStream fs = File.Create(path);
Byte[] buf = Encoding.ASCII.GetBytes(pidstring);
fs.Write(buf, 0, buf.Length);
fs.Close();
m_pidFile = path;
}
catch (Exception)
{
}
}
}
}