Ejemplo n.º 1
0
 public static void Main(string[] args)
 {
     XmlConfigurator.Configure(new System.IO.FileInfo("logging.xml"));
     Log.Debug("Loading settings");
     GlobalSettings = ReadSettings(Program.ServerHostLocation + ((args.Length > 0) ? args[0] : "Settings.xml"));
     foreach (var server in GlobalSettings.Servers)
     {
         StartServer(server);
     }
     foreach (var thread in VirtualServerThreads)
     {
         thread.Value.Join(100);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Read server settings from XML
        /// </summary>
        /// <param name="path">Server settings path</param>
        /// <returns>ServerSettings instance</returns>
        private static InstanceSettings ReadSettings(string path)
        {
            var ser = new XmlSerializer(typeof(InstanceSettings));

            InstanceSettings settings = null;

            Log.Debug(path);
            if (File.Exists(path))
            {
                using (var stream = File.OpenRead(path)) settings = (InstanceSettings)ser.Deserialize(stream);
                using (var stream = new FileStream(path, File.Exists(path) ? FileMode.Truncate : FileMode.Create, FileAccess.ReadWrite)) ser.Serialize(stream, settings);
            }
            else
            {
                Log.Debug("No settings.xml found, creating a new one.");
                using (var stream = File.OpenWrite(path)) ser.Serialize(stream, settings = new InstanceSettings());
            }
            //LogToConsole(1, false, "FILE", "Settings loaded from " + path);
            return(settings);
        }