clean up of startup config settings (command line args etc),

Now using the Nini configuration library (suggest we look into using this for the rest of our config handling, as it provides a standard interface for command line args, INI files, Xml files, .NET config files, and windows registry). 
One IMPORTANT change is that to TO START GRIDMODE , you need to now use -gridmode=true .
Also need someone to test it under mono. (there is a dll that has been compiled under mono available, just hoping that we don't have to deal with separate dlls for windows and linux.
afrisby
MW 2007-08-04 18:15:48 +00:00
parent bb60d87538
commit f1e10e555d
6 changed files with 72 additions and 102 deletions

View File

@ -28,6 +28,7 @@
using System; using System;
using OpenSim.Framework.Console; using OpenSim.Framework.Console;
using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;
using Nini.Config;
namespace OpenSim namespace OpenSim
{ {
@ -52,70 +53,16 @@ namespace OpenSim
Console.WriteLine("Starting...\n"); Console.WriteLine("Starting...\n");
bool sandBoxMode = true; ArgvConfigSource source = new ArgvConfigSource(args);
bool startLoginServer = true;
string physicsEngine = "basicphysics";
bool userAccounts = false; source.AddSwitch("Startup", "inifile");
bool gridLocalAsset = false; source.AddSwitch("Startup", "configfile");
bool useConfigFile = false; source.AddSwitch("Startup", "gridmode");
bool silent = false; source.AddSwitch("Startup", "physics");
string configFile = "simconfig.xml"; source.AddSwitch("Startup", "config");
source.AddSwitch("Startup", "noverbose");
for (int i = 0; i < args.Length; i++)
{
if (args[i] == "-gridmode")
{
sandBoxMode = false;
startLoginServer = false;
}
if (args[i] == "-accounts") OpenSimMain sim = new OpenSimMain(source);
{
userAccounts = true;
}
if (args[i] == "-realphysx")
{
physicsEngine = "RealPhysX";
}
if (args[i] == "-bulletX")
{
physicsEngine = "BulletXEngine";
}
if (args[i] == "-ode")
{
physicsEngine = "OpenDynamicsEngine";
}
if (args[i] == "-localasset")
{
gridLocalAsset = true;
}
if (args[i] == "-configfile")
{
useConfigFile = true;
}
if (args[i] == "-noverbose")
{
silent = true;
}
if (args[i] == "-config")
{
try
{
i++;
configFile = args[i];
}
catch (Exception e)
{
Console.WriteLine("-config: Please specify a config file. (" + e.ToString() + ")");
}
}
}
OpenSimMain sim = new OpenSimMain(sandBoxMode, startLoginServer, physicsEngine, useConfigFile, silent, configFile);
sim.user_accounts = userAccounts;
sim.m_gridLocalAsset = gridLocalAsset;
sim.StartUp(); sim.StartUp();

View File

@ -29,6 +29,7 @@
using System; using System;
using System.IO; using System.IO;
using libsecondlife; using libsecondlife;
using Nini.Config;
using OpenSim.Assets; using OpenSim.Assets;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Communications; using OpenSim.Framework.Communications;
@ -39,7 +40,7 @@ using OpenSim.Framework.Servers;
using OpenSim.Framework.Types; using OpenSim.Framework.Types;
using OpenSim.Framework.Configuration; using OpenSim.Framework.Configuration;
using OpenSim.Physics.Manager; using OpenSim.Physics.Manager;
using OpenSim.Region.ClientStack; using OpenSim.Region.ClientStack;
using OpenSim.Region.Communications.Local; using OpenSim.Region.Communications.Local;
using OpenSim.Region.Communications.OGS1; using OpenSim.Region.Communications.OGS1;
@ -57,7 +58,6 @@ namespace OpenSim
{ {
public string m_physicsEngine; public string m_physicsEngine;
public bool m_sandbox; public bool m_sandbox;
public bool m_loginserver;
public bool user_accounts; public bool user_accounts;
public bool m_gridLocalAsset; public bool m_gridLocalAsset;
protected bool m_useConfigFile; protected bool m_useConfigFile;
@ -70,18 +70,37 @@ namespace OpenSim
private bool m_silent; private bool m_silent;
private string m_logFilename = ("region-console-" + Guid.NewGuid().ToString() + ".log"); private string m_logFilename = ("region-console-" + Guid.NewGuid().ToString() + ".log");
public OpenSimMain(bool sandBoxMode, bool startLoginServer, string physicsEngineName, bool useConfigFile, bool silent, string configFileName) public OpenSimMain(IConfigSource configSource)
:base( ) : base()
{ {
m_useConfigFile = useConfigFile; IConfigSource startupSource = configSource;
m_sandbox = sandBoxMode; string iniFile = startupSource.Configs["Startup"].GetString("inifile", "NA");
m_loginserver = startLoginServer; if (iniFile != "NA")
m_physicsEngine = physicsEngineName; {
m_configFileName = configFileName; //a ini is set to be used for startup settings
m_silent = silent; string iniFilePath = Path.Combine(Util.configDir(), iniFile);
if (File.Exists(iniFilePath))
{
startupSource = new IniConfigSource(iniFilePath);
//enable follow line, if we want the original config source(normally commandline args) merged with ini file settings.
//in this case we have it so if both sources have the same named setting, command line value will overwrite the ini file value.
//(as if someone has bothered to enter a command line arg, we should take notice of it)
//startupSource.Merge(configSource);
}
}
ReadConfigSettings(startupSource);
}
protected void ReadConfigSettings(IConfigSource configSource)
{
m_useConfigFile = configSource.Configs["Startup"].GetBoolean("configfile", false);
m_sandbox = !configSource.Configs["Startup"].GetBoolean("gridmode", false);
m_physicsEngine = configSource.Configs["Startup"].GetString("physics", "basicphysics");
m_configFileName = configSource.Configs["Startup"].GetString("config", "simconfig.xml");
m_silent = configSource.Configs["Startup"].GetBoolean("noverbose", false);
} }
/// <summary> /// <summary>
/// Performs initialisation of the scene, such as loading configuration from disk. /// Performs initialisation of the scene, such as loading configuration from disk.
/// </summary> /// </summary>
@ -91,7 +110,7 @@ namespace OpenSim
{ {
Directory.CreateDirectory(Util.logDir()); Directory.CreateDirectory(Util.logDir());
} }
m_log = new LogBase(Path.Combine(Util.logDir(),m_logFilename), "Region", this, m_silent); m_log = new LogBase(Path.Combine(Util.logDir(), m_logFilename), "Region", this, m_silent);
MainLog.Instance = m_log; MainLog.Instance = m_log;
base.StartUp(); base.StartUp();
@ -103,11 +122,11 @@ namespace OpenSim
if (m_sandbox) if (m_sandbox)
{ {
m_commsManager = new CommunicationsLocal( m_networkServersInfo, m_httpServer, m_assetCache); m_commsManager = new CommunicationsLocal(m_networkServersInfo, m_httpServer, m_assetCache);
} }
else else
{ {
m_commsManager = new CommunicationsOGS1( m_networkServersInfo, m_httpServer , m_assetCache); m_commsManager = new CommunicationsOGS1(m_networkServersInfo, m_httpServer, m_assetCache);
} }
@ -129,15 +148,15 @@ namespace OpenSim
for (int i = 0; i < configFiles.Length; i++) for (int i = 0; i < configFiles.Length; i++)
{ {
Console.WriteLine("Loading region config file"); //Console.WriteLine("Loading region config file");
RegionInfo regionInfo = new RegionInfo("REGION CONFIG #" + (i + 1), configFiles[i]); RegionInfo regionInfo = new RegionInfo("REGION CONFIG #" + (i + 1), configFiles[i]);
UDPServer udpServer; UDPServer udpServer;
Scene scene = SetupScene(regionInfo, out udpServer); Scene scene = SetupScene(regionInfo, out udpServer);
m_localScenes.Add(scene); m_localScenes.Add(scene);
m_udpServers.Add(udpServer); m_udpServers.Add(udpServer);
m_regionData.Add(regionInfo); m_regionData.Add(regionInfo);
} }
@ -148,7 +167,7 @@ namespace OpenSim
this.m_udpServers[i].ServerListener(); this.m_udpServers[i].ServerListener();
} }
} }
protected override StorageManager CreateStorageManager(RegionInfo regionInfo) protected override StorageManager CreateStorageManager(RegionInfo regionInfo)
@ -160,10 +179,10 @@ namespace OpenSim
{ {
return new Scene(regionInfo, circuitManager, m_commsManager, m_assetCache, storageManager, m_httpServer); return new Scene(regionInfo, circuitManager, m_commsManager, m_assetCache, storageManager, m_httpServer);
} }
protected override void Initialize() protected override void Initialize()
{ {
m_networkServersInfo = new NetworkServersInfo("NETWORK SERVERS INFO", Path.Combine(Util.configDir(),"network_servers_information.xml")); m_networkServersInfo = new NetworkServersInfo("NETWORK SERVERS INFO", Path.Combine(Util.configDir(), "network_servers_information.xml"));
m_httpServerPort = m_networkServersInfo.HttpListenerPort; m_httpServerPort = m_networkServersInfo.HttpListenerPort;
m_assetCache = new AssetCache("OpenSim.Region.GridInterfaces.Local.dll", m_networkServersInfo.AssetURL, m_networkServersInfo.AssetSendKey); m_assetCache = new AssetCache("OpenSim.Region.GridInterfaces.Local.dll", m_networkServersInfo.AssetURL, m_networkServersInfo.AssetSendKey);
} }
@ -174,15 +193,15 @@ namespace OpenSim
{ {
Directory.CreateDirectory(Util.logDir()); Directory.CreateDirectory(Util.logDir());
} }
return new LogBase((Path.Combine(Util.logDir(),m_logFilename)), "Region", this, m_silent); return new LogBase((Path.Combine(Util.logDir(), m_logFilename)), "Region", this, m_silent);
} }
# region Setup methods # region Setup methods
protected override PhysicsScene GetPhysicsScene( ) protected override PhysicsScene GetPhysicsScene()
{ {
return GetPhysicsScene( m_physicsEngine ); return GetPhysicsScene(m_physicsEngine);
} }
private class SimStatusHandler : IStreamHandler private class SimStatusHandler : IStreamHandler
@ -201,7 +220,7 @@ namespace OpenSim
{ {
get { return "GET"; } get { return "GET"; }
} }
public string Path public string Path
{ {
get { return "/simstatus/"; } get { return "/simstatus/"; }

View File

@ -57,7 +57,7 @@ namespace OpenSim.Region.Environment
return false; return false;
SceneObject task = (SceneObject)m_scene.Entities[obj]; SceneObject task = (SceneObject)m_scene.Entities[obj];
LLUUID taskOwner = null; // Since we dont have a 'owner' property on task yet LLUUID taskOwner = task.rootPrimitive.OwnerID;
// Object owners should be able to edit their own content // Object owners should be able to edit their own content
if (user == taskOwner) if (user == taskOwner)

View File

@ -94,16 +94,24 @@ namespace OpenSim.Region.Environment.Scenes
return dupe; return dupe;
} }
/// <summary>
///
/// </summary>
/// <param name="part"></param>
public void CopyRootPart(AllNewSceneObjectPart2 part) public void CopyRootPart(AllNewSceneObjectPart2 part)
{ {
AllNewSceneObjectPart2 newPart = part.Copy(m_scene); AllNewSceneObjectPart2 newPart = part.Copy(m_scene.PrimIDAllocate());
this.m_parts.Add(newPart.UUID, newPart); this.m_parts.Add(newPart.UUID, newPart);
this.SetPartAsRoot(newPart); this.SetPartAsRoot(newPart);
} }
/// <summary>
///
/// </summary>
/// <param name="part"></param>
public void CopyPart(AllNewSceneObjectPart2 part) public void CopyPart(AllNewSceneObjectPart2 part)
{ {
AllNewSceneObjectPart2 newPart = part.Copy(m_scene); AllNewSceneObjectPart2 newPart = part.Copy(m_scene.PrimIDAllocate());
this.m_parts.Add(newPart.UUID, newPart); this.m_parts.Add(newPart.UUID, newPart);
this.SetPartAsNonRoot(newPart); this.SetPartAsNonRoot(newPart);
} }

View File

@ -27,7 +27,7 @@ namespace OpenSim.Region.Environment.Scenes
public uint EveryoneMask = FULL_MASK_PERMISSIONS; public uint EveryoneMask = FULL_MASK_PERMISSIONS;
public uint BaseMask = FULL_MASK_PERMISSIONS; public uint BaseMask = FULL_MASK_PERMISSIONS;
protected PrimitiveBaseShape m_shape;
protected byte[] m_particleSystem = new byte[0]; protected byte[] m_particleSystem = new byte[0];
protected AllNewSceneObjectGroup2 m_parentGroup; protected AllNewSceneObjectGroup2 m_parentGroup;
@ -54,9 +54,6 @@ namespace OpenSim.Region.Environment.Scenes
} }
protected string m_name; protected string m_name;
/// <summary>
///
/// </summary>
public virtual string Name public virtual string Name
{ {
get { return m_name; } get { return m_name; }
@ -154,9 +151,9 @@ namespace OpenSim.Region.Environment.Scenes
set { m_touchName = value; } set { m_touchName = value; }
} }
protected PrimitiveBaseShape m_shape;
public PrimitiveBaseShape Shape public PrimitiveBaseShape Shape
{ {
get { return this.m_shape; } get { return this.m_shape; }
set { m_shape = value; } set { m_shape = value; }
} }
@ -245,14 +242,13 @@ namespace OpenSim.Region.Environment.Scenes
/// ///
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public AllNewSceneObjectPart2 Copy(Scene scene) public AllNewSceneObjectPart2 Copy(uint localID)
{ {
AllNewSceneObjectPart2 dupe = (AllNewSceneObjectPart2)this.MemberwiseClone(); AllNewSceneObjectPart2 dupe = (AllNewSceneObjectPart2)this.MemberwiseClone();
dupe.m_shape = m_shape.Copy(); dupe.m_shape = m_shape.Copy();
dupe.m_regionHandle = m_regionHandle; dupe.m_regionHandle = m_regionHandle;
uint newLocalID = scene.PrimIDAllocate();
dupe.UUID = LLUUID.Random(); dupe.UUID = LLUUID.Random();
dupe.LocalID = newLocalID; dupe.LocalID = localID;
dupe.OffsetPosition = new LLVector3(OffsetPosition.X, OffsetPosition.Y, OffsetPosition.Z); dupe.OffsetPosition = new LLVector3(OffsetPosition.X, OffsetPosition.Y, OffsetPosition.Z);
dupe.RotationOffset = new LLQuaternion(RotationOffset.X, RotationOffset.Y, RotationOffset.Z, RotationOffset.W); dupe.RotationOffset = new LLQuaternion(RotationOffset.X, RotationOffset.Y, RotationOffset.Z, RotationOffset.W);
dupe.Velocity = new LLVector3(0, 0, 0); dupe.Velocity = new LLVector3(0, 0, 0);
@ -303,7 +299,7 @@ namespace OpenSim.Region.Environment.Scenes
} }
else else
{ {
if (m_updateFlag == 2) // is a new prim just been created/reloaded or has major changes if (m_updateFlag == 2) // is a new prim, just created/reloaded or has major changes
{ {
SendFullUpdateToAllClients(); SendFullUpdateToAllClients();
ClearUpdateSchedule(); ClearUpdateSchedule();

View File

@ -666,7 +666,7 @@
<Reference name="XMLRPC.dll"/> <Reference name="XMLRPC.dll"/>
<Reference name="OpenSim.Framework.UserManagement" /> <Reference name="OpenSim.Framework.UserManagement" />
<Reference name="OpenSim.Region.Communications.Local"/> <Reference name="OpenSim.Region.Communications.Local"/>
<Reference name="Nini.dll" />
<Files> <Files>
<Match pattern="*.cs" recurse="true"/> <Match pattern="*.cs" recurse="true"/>
</Files> </Files>