public ServiceSettingsConfigProxy(string serviceName, string computerName) { _runMode = ServiceRunMode.Unknown; ServiceEnvironment.ServiceName = serviceName; ServiceEnvironment.ComputerNameForConfiguration = computerName; _section = IICConfigSection.CreateDefault <ServiceSettingsConfigSection>(); _section.ServiceName = serviceName; }
// // Nothing in public ServiceSettingsConfigProxy(string serviceName, string computerName) { _runMode = ServiceRunMode.Unknown; _section = IICConfigSection.CreateDefault<ServiceSettingsConfigSection>(); _serviceName = serviceName; _section.ServiceName = serviceName; Process process = Process.GetCurrentProcess(); _computerName = computerName.ToUpper(); _workPath = AppDomain.CurrentDomain.BaseDirectory; }
// // Nothing in public ServiceSettingsConfigProxy(string serviceName, string computerName) { _runMode = ServiceRunMode.Unknown; _section = IICConfigSection.CreateDefault <ServiceSettingsConfigSection>(); _serviceName = serviceName; _section.ServiceName = serviceName; Process process = Process.GetCurrentProcess(); _computerName = computerName.ToUpper(); _workPath = AppDomain.CurrentDomain.BaseDirectory; }
public void UpdateConfig(ServiceRunMode runMode, HAServiceSettings serviceSettings) { // // 不允许更新 _runMode = runMode; _section = IICConfigurationManager.Configurator.GetConfigSecion <ServiceSettingsConfigSection>( "ServiceSettings", null); // // 优先使用本地配置 _domain = _section.Domain; _site = _section.Site; int.TryParse(_section.PoolID, out _poolId); _pools = new List <int>(); foreach (string a in _section.Pools.Split(',')) { int p; if (int.TryParse(a, out p)) { _pools.Add(p); } } // // HA模式下, 如果ServiceSettings没有配置, 会使用来自HA_Computer与HA_Deployment的配置覆盖 // Pool, Site, Domain三项配置 switch (_runMode) { case ServiceRunMode.LocalWeb: case ServiceRunMode.LocalService: if (string.IsNullOrEmpty(_serviceRoleName)) { _serviceRoleName = _section.ServiceName; } break; case ServiceRunMode.HAService: case ServiceRunMode.HAWeb: // // 在HA方式下运行的服务, 可以通过ServiceSettings配置节, 替换ServiceSettings的配置 if (serviceSettings != null) { _serviceRoleName = serviceSettings.ServiceOriginName; if (string.IsNullOrEmpty(_domain)) { _domain = serviceSettings.Domain; } if (string.IsNullOrEmpty(_site)) { _site = serviceSettings.Site; } if (string.IsNullOrEmpty(_section.PoolID)) { _poolId = serviceSettings.PoolId; } } break; default: throw new NotSupportedException("Unexcepted RunMode:" + _runMode); } }
public void UpdateConfig(ServiceRunMode runMode, HAServiceSettings serviceSettings) { _runMode = runMode; _section = IICConfigurationManager.Configurator.GetConfigSecion<ServiceSettingsConfigSection>("ServiceSettings", null); // // 优先使用本地配置 _domain = _section.Domain; _site = _section.Site; int.TryParse(_section.PoolID, out _poolId); _pools = new List<int>(); foreach (string a in _section.Pools.Split(',')) { int p; if (int.TryParse(a, out p)) { _pools.Add(p); } } // // HA模式下, 如果ServiceSettings没有配置, 会使用来自HA_Computer与HA_Deployment的配置覆盖 // Pool, Site, Domain三项配置 // // BTW domain is not usable switch (_runMode) { case ServiceRunMode.LocalWeb: case ServiceRunMode.LocalService: if (string.IsNullOrEmpty(_serviceRoleName)) { _serviceRoleName = _section.ServiceName; } break; case ServiceRunMode.HAService: case ServiceRunMode.HAWeb: // // if (serviceSettings != null) { _serviceRoleName = serviceSettings.ServiceOriginName; if (string.IsNullOrEmpty(_domain)) { _domain = serviceSettings.Domain; } if (string.IsNullOrEmpty(_section.Site)) { _site = serviceSettings.Site; } if (string.IsNullOrEmpty(_section.PoolID)) { _poolId = serviceSettings.PoolId; } } break; default: throw new NotSupportedException("Unexcepted RunMode:" + _runMode); } ServiceEnviornment.ComputerName = _computerName; ServiceEnviornment.ServiceName = _serviceName; }