Changes to prepare for future possible configuration of separate logdir, configdir, datadir.

afrisby
Brian McBee 2007-08-03 18:01:55 +00:00
parent 0975ff6cfd
commit 599a6d32ee
11 changed files with 95 additions and 18 deletions

View File

@ -31,6 +31,7 @@ using System.Xml;
using OpenSim.Framework.Interfaces;
using OpenSim.Framework.Configuration.Interfaces;
using OpenSim.Framework.Utilities;
namespace OpenSim.Framework.Configuration
{
@ -119,6 +120,11 @@ namespace OpenSim.Framework.Configuration
public void Commit()
{
if (!Directory.Exists(Util.configDir()))
{
Directory.CreateDirectory(Util.configDir());
}
doc.Save(fileName);
}

View File

@ -63,6 +63,7 @@ namespace OpenSim.Framework.Console
}
System.Console.WriteLine("Logs will be saved to current directory in " + LogFile);
Log = File.AppendText(LogFile);
Log.WriteLine("========================================================================");
Log.WriteLine(componentname + " Started at " + DateTime.Now.ToString());

View File

@ -26,7 +26,9 @@
*
*/
using System;
using System.IO;
using libsecondlife;
using OpenSim.Framework.Utilities;
namespace OpenSim.Framework.Data.DB4o
{
@ -45,7 +47,7 @@ namespace OpenSim.Framework.Data.DB4o
/// </summary>
public void Initialise()
{
manager = new DB4oUserManager("userprofiles.yap");
manager = new DB4oUserManager(Path.Combine(Util.dataDir(),"userprofiles.yap"));
}
/// <summary>

View File

@ -25,9 +25,11 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System.IO;
using libsecondlife;
using OpenSim.Framework.Configuration;
using OpenSim.Framework.Utilities;
namespace OpenSim.Framework.Types
{
public class EstateSettings
@ -554,7 +556,7 @@ namespace OpenSim.Framework.Types
private ConfigurationMember configMember;
public EstateSettings()
{
configMember = new ConfigurationMember("estate_settings.xml", "ESTATE SETTINGS", this.loadConfigurationOptions, this.handleIncomingConfiguration);
configMember = new ConfigurationMember(Path.Combine(Util.configDir(),"estate_settings.xml"), "ESTATE SETTINGS", this.loadConfigurationOptions, this.handleIncomingConfiguration);
configMember.performConfigurationRetrieve();
}

View File

@ -26,6 +26,7 @@
*
*/
using System;
using System.IO;
using System.Security.Cryptography;
using System.Net;
using System.Text;
@ -275,6 +276,39 @@ namespace OpenSim.Framework.Utilities
return null;
}
//
// directory locations
//
public static string homeDir()
{
string temp;
// string personal=(Environment.GetFolderPath(Environment.SpecialFolder.Personal));
// temp = Path.Combine(personal,".OpenSim");
temp=".";
return temp;
}
public static string configDir()
{
string temp;
temp = ".";
return temp;
}
public static string dataDir()
{
string temp;
temp = ".";
return temp;
}
public static string logDir()
{
string temp;
temp = ".";
return temp;
}
public Util()
{

View File

@ -34,6 +34,7 @@ using libsecondlife;
using OpenSim.Framework.Console;
using OpenSim.Framework.Types;
using OpenSim.Framework.Servers;
using OpenSim.Framework.Utilities;
namespace OpenSim.Grid.AssetServer
{
@ -71,7 +72,11 @@ namespace OpenSim.Grid.AssetServer
private OpenAsset_Main()
{
m_console = new LogBase("opengrid-AssetServer-console.log", "OpenAsset", this, false);
if(!Directory.Exists(Util.logDir()))
{
Directory.CreateDirectory(Util.logDir());
}
m_console = new LogBase((Path.Combine(Util.logDir(),"opengrid-AssetServer-console.log")), "OpenAsset", this, false);
MainLog.Instance = m_console;
}
@ -154,10 +159,11 @@ namespace OpenSim.Grid.AssetServer
public void setupDB()
{
bool yapfile = File.Exists("gridassets.yap");
string yappath=(Path.Combine(Util.dataDir(),"gridassets.yap"));
bool yapfile = File.Exists(yappath);
try
{
db = Db4oFactory.OpenFile("gridassets.yap");
db = Db4oFactory.OpenFile(yappath);
MainLog.Instance.Verbose("storage", "Main.cs:setupDB() - creation");
}
catch (Exception e)

View File

@ -27,6 +27,7 @@
*/
using System;
using System.IO;
using System.Reflection;
using System.Threading;
using System.Timers;
@ -34,6 +35,7 @@ using OpenSim.Framework.Console;
using OpenSim.Framework.Interfaces;
using OpenSim.Framework.Servers;
using OpenSim.Framework.Configuration;
using OpenSim.Framework.Utilities;
using Timer=System.Timers.Timer;
@ -84,7 +86,11 @@ namespace OpenSim.Grid.GridServer
private OpenGrid_Main()
{
m_console = new LogBase("opengrid-gridserver-console.log", "OpenGrid", this, false);
if (!Directory.Exists(Util.logDir()))
{
Directory.CreateDirectory(Util.logDir());
}
m_console = new LogBase((Path.Combine(Util.logDir(),"opengrid-gridserver-console.log")), "OpenGrid", this, false);
MainLog.Instance = m_console;
@ -104,7 +110,7 @@ namespace OpenSim.Grid.GridServer
public void Startup()
{
this.Cfg = new GridConfig("GRID SERVER","GridServer_Config.xml"); //Yeah srsly, that's it.
this.Cfg = new GridConfig("GRID SERVER",(Path.Combine(Util.configDir(),"GridServer_Config.xml"))); //Yeah srsly, that's it.
if (setuponly) Environment.Exit(0);
m_console.Verbose( "Main.cs:Startup() - Connecting to Storage Server");

View File

@ -28,6 +28,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using libsecondlife;
using OpenSim.Framework.Console;
@ -64,7 +65,11 @@ namespace OpenSim.Grid.UserServer
private OpenUser_Main()
{
m_console = new LogBase("opengrid-userserver-console.log", "OpenUser", this , false);
if (!Directory.Exists(Util.logDir()))
{
Directory.CreateDirectory(Util.logDir());
}
m_console = new LogBase((Path.Combine(Util.logDir(),"opengrid-userserver-console.log")), "OpenUser", this , false);
MainLog.Instance = m_console;
}
@ -80,7 +85,7 @@ namespace OpenSim.Grid.UserServer
public void Startup()
{
this.Cfg = new UserConfig("USER SERVER", "UserServer_Config.xml");
this.Cfg = new UserConfig("USER SERVER", (Path.Combine(Util.configDir(), "UserServer_Config.xml")));
MainLog.Instance.Verbose("Main.cs:Startup() - Establishing data connection");
m_userManager = new UserManager();

View File

@ -68,7 +68,7 @@ namespace OpenSim
protected List<IScene> m_localScenes = new List<IScene>();
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)
:base( )
@ -87,7 +87,11 @@ namespace OpenSim
/// </summary>
public override void StartUp()
{
m_log = new LogBase(m_logFilename, "Region", this, m_silent);
if (!Directory.Exists(Util.logDir()))
{
Directory.CreateDirectory(Util.logDir());
}
m_log = new LogBase(Path.Combine(Util.logDir(),m_logFilename), "Region", this, m_silent);
MainLog.Instance = m_log;
base.StartUp();
@ -106,12 +110,17 @@ namespace OpenSim
m_commsManager = new CommunicationsOGS1( m_networkServersInfo, m_httpServer , m_assetCache);
}
string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Regions");
string path = Path.Combine(Util.configDir(), "Regions");
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
string[] configFiles = Directory.GetFiles(path, "*.xml");
if (configFiles.Length == 0)
{
string path2 = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Regions");
string path2 = Path.Combine(Util.configDir(), "Regions");
string path3 = Path.Combine(path2, "default.xml");
RegionInfo regionInfo = new RegionInfo("DEFAULT REGION CONFIG", path3);
@ -154,14 +163,19 @@ namespace OpenSim
protected override void Initialize()
{
m_networkServersInfo = new NetworkServersInfo("NETWORK SERVERS INFO", "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_assetCache = new AssetCache("OpenSim.Region.GridInterfaces.Local.dll", m_networkServersInfo.AssetURL, m_networkServersInfo.AssetSendKey);
}
protected override LogBase CreateLog()
{
return new LogBase(m_logFilename, "Region", this, m_silent);
if (!Directory.Exists(Util.logDir()))
{
Directory.CreateDirectory(Util.logDir());
}
return new LogBase((Path.Combine(Util.logDir(),m_logFilename)), "Region", this, m_silent);
}
# region Setup methods

View File

@ -62,10 +62,10 @@ namespace OpenSim.Region.GridInterfaces.Local
{
bool yapfile;
this._assetRequests = new BlockingQueue<ARequest>();
yapfile = File.Exists("regionassets.yap");
yapfile = File.Exists(Path.Combine(Util.dataDir(),"regionassets.yap"));
MainLog.Instance.Verbose("Local Asset Server class created");
db = Db4oFactory.OpenFile("regionassets.yap");
db = Db4oFactory.OpenFile(Path.Combine(Util.dataDir(),"regionassets.yap"));
MainLog.Instance.Verbose("Db4 Asset database creation");
if (!yapfile)

View File

@ -367,6 +367,7 @@
<Reference name="System" localCopy="false"/>
<Reference name="System.Xml"/>
<Reference name="System.Data"/>
<Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Framework.Data"/>
<Reference name="libsecondlife.dll"/>
<Reference name="Db4objects.Db4o.dll"/>