From: <mis...@us...> - 2007-03-09 14:19:10
|
Revision: 32 http://svn.sourceforge.net/mp-webinterface/?rev=32&view=rev Author: misterd_sf Date: 2007-03-09 06:19:08 -0800 (Fri, 09 Mar 2007) Log Message: ----------- Added two custom commands: Reload Configuration and Reinit Logging Modified Paths: -------------- trunk/Version2/WebServer/Server.cs trunk/Version2/WebServer/WebServer.csproj trunk/Version2/WindowsService/Service.Designer.cs trunk/Version2/WindowsService/Service.cs Added Paths: ----------- trunk/Version2/WebServer/CustomCommands.cs Added: trunk/Version2/WebServer/CustomCommands.cs =================================================================== --- trunk/Version2/WebServer/CustomCommands.cs (rev 0) +++ trunk/Version2/WebServer/CustomCommands.cs 2007-03-09 14:19:08 UTC (rev 32) @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace MPW.WebServer { + /// <summary> + /// Enumeration of known Custom Commands of the server and windows service + /// </summary> + public enum CustomCommands { + /// <summary> + /// Reloads the configuration and also filename from AppConfig. + /// </summary> + ReloadConfiguration=128, + /// <summary> + /// Reinits logging and reading the new config file name from AppConfig. + /// </summary> + ReinitLogging=129 + } +} Modified: trunk/Version2/WebServer/Server.cs =================================================================== --- trunk/Version2/WebServer/Server.cs 2007-03-09 09:30:00 UTC (rev 31) +++ trunk/Version2/WebServer/Server.cs 2007-03-09 14:19:08 UTC (rev 32) @@ -146,8 +146,16 @@ } finally { _host = null; log.Debug("Web server stopped."); + _shutdownInProgress = false; } } + public void Reload(ServerConfiguration configuration) { + Stop(); + _configuration = configuration; + String tempPhysicalPath = configuration.PhysicalPath; + _configuration.PhysicalPath = tempPhysicalPath.EndsWith("\\", StringComparison.Ordinal) ? tempPhysicalPath : tempPhysicalPath + "\\"; + Start(); + } #endregion #region event handling Modified: trunk/Version2/WebServer/WebServer.csproj =================================================================== --- trunk/Version2/WebServer/WebServer.csproj 2007-03-09 09:30:00 UTC (rev 31) +++ trunk/Version2/WebServer/WebServer.csproj 2007-03-09 14:19:08 UTC (rev 32) @@ -48,6 +48,7 @@ <ItemGroup> <Compile Include="ByteParser.cs" /> <Compile Include="ByteString.cs" /> + <Compile Include="CustomCommands.cs" /> <Compile Include="ServerConfiguration.cs" /> <Compile Include="Connection.cs" /> <Compile Include="Host.cs" /> Modified: trunk/Version2/WindowsService/Service.Designer.cs =================================================================== --- trunk/Version2/WindowsService/Service.Designer.cs 2007-03-09 09:30:00 UTC (rev 31) +++ trunk/Version2/WindowsService/Service.Designer.cs 2007-03-09 14:19:08 UTC (rev 32) @@ -26,7 +26,7 @@ this.eventLog = new System.Diagnostics.EventLog(); ((System.ComponentModel.ISupportInitialize)(this.eventLog)).BeginInit(); // - // MPW_Service + // Service // this.CanHandlePowerEvent = true; this.CanPauseAndContinue = true; Modified: trunk/Version2/WindowsService/Service.cs =================================================================== --- trunk/Version2/WindowsService/Service.cs 2007-03-09 09:30:00 UTC (rev 31) +++ trunk/Version2/WindowsService/Service.cs 2007-03-09 14:19:08 UTC (rev 32) @@ -115,6 +115,18 @@ /// </summary> /// <param name="command">Command code</param> protected override void OnCustomCommand(int command) { + CustomCommands custCommand = (CustomCommands)command; + switch (custCommand) { + case CustomCommands.ReloadConfiguration: + String configFile = System.AppDomain.CurrentDomain.BaseDirectory + "\\" + ConfigurationManager.AppSettings["ConfigurationFile"]; + _configuration = ServerConfiguration.readConfiguration(configFile); + _server.Reload(_configuration); + break; + case CustomCommands.ReinitLogging: + string loggingConfigFile = System.AppDomain.CurrentDomain.BaseDirectory + "\\" + ConfigurationManager.AppSettings["LoggingConfigurationFile"]; + XmlConfigurator.ConfigureAndWatch(new FileInfo(loggingConfigFile)); + break; + } base.OnCustomCommand(command); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |