/// <summary> /// Initializes a new instance of the <see cref="IisApplicationPool"/> class. /// </summary> /// <param name="poolName"> /// The pool name. /// </param> /// <param name="managedRuntimeVersion"> /// The managed Runtime Version. /// </param> /// <param name="pipeline"> /// The pipeline. /// </param> /// <param name="enable32BitAppOnWin64">determines if enable32BitAppOnWin64 is required for the pool</param> public IisApplicationPool(string poolName, string managedRuntimeVersion = DefaultManagedRuntimeVersion, string pipeline = DefaultPipeline, bool enable32BitAppOnWin64 = false) { try { this.serverManager = new ServerManager(); this.Name = poolName; if (this.serverManager.ApplicationPools[poolName] != null) { // Removing the existing pool and recreating // as existing pool sometimes cause issues this.Remove(); } this.iisPool = this.serverManager.ApplicationPools.Add(poolName); this.iisPool.ManagedRuntimeVersion = managedRuntimeVersion; this.iisPool.ManagedPipelineMode = pipeline.Equals(DefaultPipeline, StringComparison.OrdinalIgnoreCase) ? ManagedPipelineMode.Integrated : ManagedPipelineMode.Classic; this.iisPool.Enable32BitAppOnWin64 = enable32BitAppOnWin64; this.iisPool.ProcessModel.IdentityType = ProcessModelIdentityType.NetworkService; this.serverManager.CommitChanges(); Trace.TraceInformation( "IISApplication Pool {0} created successfully.", poolName); } catch (Exception ex) { Trace.TraceError("Exception occured while creating IIS Application Pool: {0}. The exception thrown was {1}", poolName, ex.Message); } }
internal override async Task<bool> GetPoolStateAsync(ApplicationPool pool) { #if !__MonoCS__ using (PowerShell PowerShellInstance = PowerShell.Create()) { // use "AddScript" to add the contents of a script file to the end of the execution pipeline. // use "AddCommand" to add individual commands/cmdlets to the end of the execution pipeline. PowerShellInstance.AddScript("param($param1) [Reflection.Assembly]::LoadFrom('C:\\Windows\\system32\\inetsrv\\Microsoft.Web.Administration.dll'); Get-IISAppPool -Name \"$param1\""); // use "AddParameter" to add a single parameter to the last command/script on the pipeline. PowerShellInstance.AddParameter("param1", pool.Name); Collection<PSObject> PSOutput = PowerShellInstance.Invoke(); // check the other output streams (for example, the error stream) if (PowerShellInstance.Streams.Error.Count > 0) { // error records were written to the error stream. // do something with the items found. return false; } dynamic site = PSOutput[1]; return site.State?.ToString() == "Started"; } #else return false; #endif }
public void SetupApplication() { VirtualDirectoryName = new DirectoryInfo(_startParameters.ApplicationPath).Parent.Name; _applicationPool = CreateAppPool(VirtualDirectoryName); _application = Website.Applications.Add("/" + VirtualDirectoryName, _startParameters.ApplicationPath); _application.ApplicationPoolName = _applicationPool.Name; _serverManager.CommitChanges(); }
public ApplicationPoolConfigurer(ApplicationPool applicationPool) { if (applicationPool == null) { throw new ArgumentNullException("applicationPool"); } _applicationPool = applicationPool; }
protected void LoadVirtualDirectory() { using (var iis = ServerManager.OpenRemote("localhost")) { var site = iis.Sites[WebSiteName]; var appPath = "/" + VirtualDirectory; application = site.Applications[appPath]; vDir = application.VirtualDirectories["/"]; applicationPool = iis.ApplicationPools[application.ApplicationPoolName]; } }
bool CheckState(Microsoft.Web.Administration.ApplicationPool pool, ObjectState state, int waitSecond) { int waitNum = waitSecond * 10; while (pool.State != state && waitNum > 0) { waitNum--; Thread.Sleep(100); } return(pool.State == state); }
public void DeleteSite(string applicationName) { var iis = new IIS.ServerManager(); // Get the app pool for this application string appPoolName = GetAppPool(applicationName); IIS.ApplicationPool kuduPool = iis.ApplicationPools[appPoolName]; // Make sure the acls are gone RemoveAcls(applicationName, appPoolName); if (kuduPool == null) { // If there's no app pool then do nothing return; } DeleteSite(iis, GetLiveSite(applicationName)); DeleteSite(iis, GetDevSite(applicationName)); // Don't delete the physical files for the service site DeleteSite(iis, GetServiceSite(applicationName), deletePhysicalFiles: false); iis.CommitChanges(); string appPath = _pathResolver.GetApplicationPath(applicationName); var sitePath = _pathResolver.GetLiveSitePath(applicationName); var devPath = _pathResolver.GetDeveloperApplicationPath(applicationName); try { kuduPool.StopAndWait(); DeleteSafe(sitePath); DeleteSafe(devPath); DeleteSafe(appPath); } catch (Exception ex) { Debug.WriteLine(ex.ToString()); } finally { // Remove the app pool and commit changes iis.ApplicationPools.Remove(iis.ApplicationPools[appPoolName]); iis.CommitChanges(); // Clear out the app pool user profile directory if it exists string userDir = Path.GetDirectoryName(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile).TrimEnd(Path.DirectorySeparatorChar)); string appPoolDirectory = Path.Combine(userDir, appPoolName); DeleteSafe(appPoolDirectory); } }
protected void CreateApplicationPool() { using (var iis = ServerManager.OpenRemote(WebServerName)) { AppPool = iis.ApplicationPools[ApplicationPoolName]; if (AppPool == null) { AppPool = iis.ApplicationPools.Add(ApplicationPoolName); iis.CommitChanges(); WaitForIis(); } } }
private string GetScheduleString(ApplicationPool iisPoolObject) { ScheduleCollection scheduleCollection = iisPoolObject.Recycling.PeriodicRestart.Schedule; if (scheduleCollection.Count == 0) return ""; //"\"\""; string result = ""; result += string.Join(", ", scheduleCollection.Select(s => s.Time)); return "@(\""+ result.Trim() +"\")" ; }
private static void poolIdentity(Website website, ApplicationPool pool) { if (website.IdentityType.IsEmpty()) return; if (website.HasCredentials()) { pool.ProcessModel.IdentityType = ProcessModelIdentityType.SpecificUser; pool.ProcessModel.UserName = website.Username; pool.ProcessModel.Password = website.Password; return; } var t = (ProcessModelIdentityType) Enum.Parse(typeof (ProcessModelIdentityType), website.IdentityType, true); pool.ProcessModel.IdentityType = t; }
public void DeleteSite(string applicationName) { var iis = new IIS.ServerManager(); // Get the app pool for this application string appPoolName = GetAppPool(applicationName); IIS.ApplicationPool kuduPool = iis.ApplicationPools[appPoolName]; // Make sure the acls are gone RemoveAcls(applicationName, appPoolName); if (kuduPool == null) { // If there's no app pool then do nothing return; } DeleteSite(iis, GetLiveSite(applicationName)); DeleteSite(iis, GetDevSite(applicationName)); // Don't delete the physical files for the service site DeleteSite(iis, GetServiceSite(applicationName), deletePhysicalFiles: false); iis.CommitChanges(); string appPath = _pathResolver.GetApplicationPath(applicationName); var sitePath = _pathResolver.GetLiveSitePath(applicationName); var devPath = _pathResolver.GetDeveloperApplicationPath(applicationName); try { kuduPool.StopAndWait(); DeleteSafe(sitePath); DeleteSafe(devPath); DeleteSafe(appPath); } catch (Exception ex) { Debug.WriteLine(ex.ToString()); } finally { // Remove the app pool and commit changes iis.ApplicationPools.Remove(iis.ApplicationPools[appPoolName]); iis.CommitChanges(); } }
public async Task DeleteSiteAsync(string applicationName) { using (var iis = GetServerManager()) { // Get the app pool for this application string appPoolName = GetAppPool(applicationName); IIS.ApplicationPool kuduPool = iis.ApplicationPools[appPoolName]; if (kuduPool == null) { // If there's no app pool then do nothing return; } await Task.WhenAll( DeleteSiteAsync(iis, GetLiveSite(applicationName)), // Don't delete the physical files for the service site DeleteSiteAsync(iis, GetServiceSite(applicationName), deletePhysicalFiles : false) ); iis.CommitChanges(); string appPath = _pathResolver.GetApplicationPath(applicationName); var sitePath = _pathResolver.GetLiveSitePath(applicationName); try { DeleteSafe(sitePath); DeleteSafe(appPath); } catch (Exception ex) { Debug.WriteLine(ex.ToString()); } finally { // Remove the app pool and commit changes iis.ApplicationPools.Remove(iis.ApplicationPools[appPoolName]); iis.CommitChanges(); // Clear out the app pool user profile directory if it exists string userDir = Path.GetDirectoryName(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile).TrimEnd(Path.DirectorySeparatorChar)); string appPoolDirectory = Path.Combine(userDir, appPoolName); DeleteSafe(appPoolDirectory); } } }
private void Initialize(ApplicationPool iisPoolObject, IISCodeGenerator.IisPoolAndSitesOptions iisOptions) { this.Key = GetPoolVariableName(iisPoolObject.Name); this.AddAttribute("Name", iisPoolObject.Name); if (iisOptions.KeepAppPoolsRunning) { this.AddAttributeWithOverrideValue("AutoStart", "True", iisPoolObject.AutoStart.ToString()); } this.AddAttribute("ManagedPipelineMode", iisPoolObject.ManagedPipelineMode.ToString()); this.AddAttribute("ManagedRuntimeVersion", iisPoolObject.ManagedRuntimeVersion); this.AddAttribute("IdentityType", iisPoolObject.ProcessModel.IdentityType.ToString()); this.AddAttribute("Enable32BitAppOnWin64", iisPoolObject.Enable32BitAppOnWin64.ToString()); if (iisOptions.StandardizeAppPoolRecycles) { this.AddAttributeWithOverrideValue("RestartSchedule", "@(\"02:00:00\")", GetScheduleString(iisPoolObject)); } else { this.AddAttribute("RestartSchedule", GetScheduleString(iisPoolObject)); } if (iisOptions.KeepAppPoolsRunning) { this.AddAttributeWithOverrideValue("IdleTimeout", "00:00:00", iisPoolObject.ProcessModel.IdleTimeout.ToString()); this.AddAttributeWithOverrideValue("RestartTimeLimit", "00:00:00", iisPoolObject.Recycling.PeriodicRestart.Time.ToString()); } else { this.AddAttribute("IdleTimeout", iisPoolObject.ProcessModel.IdleTimeout.ToString()); this.AddAttribute("RestartTimeLimit", iisPoolObject.Recycling.PeriodicRestart.Time.ToString()); } }
public ResponseMessage.ResponseMessage CreateAppPool(ApplicationPool appPool) { try { bool checkAppPool = CheckAppPool(appPool); if (!checkAppPool) { ServerManager serverManager = new ServerManager(); Microsoft.Web.Administration.ApplicationPool pool = serverManager.ApplicationPools.Add(appPool.applicationName); pool.Enable32BitAppOnWin64 = appPool.Enable32Bit; pool.ManagedPipelineMode = (appPool.mode == "integrated " ? ManagedPipelineMode.Integrated : ManagedPipelineMode.Classic); pool.ManagedRuntimeVersion = "v" + appPool.runTimeVersion; pool.Failure.RapidFailProtection = appPool.enableRapidFailure; serverManager.CommitChanges(); Models.ResponseMessage.ResponseMessage rm = new ResponseMessage.ResponseMessage(); rm.type = "success"; rm.message = "Anwendungspool erfolgreich erstellt"; return(rm); } else { Models.ResponseMessage.ResponseMessage rm = new ResponseMessage.ResponseMessage(); rm.type = "error"; rm.message = "Anwendungspool existiert bereits"; return(rm); } } catch (Exception ex) { Models.Logger.Logger.CreateLogFile(ex.ToString()); Models.ResponseMessage.ResponseMessage rm = new ResponseMessage.ResponseMessage(); rm.type = "error"; rm.message = ex.ToString(); return(rm); } }
private void UpdateApplications(WebSite site, ServerManager serverManager, string siteName, string sitePath, ApplicationPool appPool) { var iisSites = serverManager.Sites; var adminSite = iisSites[AzureRoleEnvironment.RoleWebsiteName()]; var testApplication = adminSite.Applications.FirstOrDefault( app => app.Path.EndsWith("/test/" + siteName, StringComparison.OrdinalIgnoreCase)); var cdnApplication = adminSite.Applications.FirstOrDefault( app => app.Path.EndsWith("/cdn/" + siteName, StringComparison.OrdinalIgnoreCase)); if (site.EnableTestChildApplication) { if (testApplication == null) { _logger.InfoFormat("Adding Test application for site '{0}'", siteName); testApplication = adminSite.Applications.Add("/test/" + siteName, sitePath); testApplication.ApplicationPoolName = appPool.Name; } } else { if (testApplication != null) { _logger.InfoFormat("Removing Test application for site '{0}'", siteName); adminSite.Applications.Remove(testApplication); } } if (site.EnableCDNChildApplication) { if (cdnApplication == null) { _logger.InfoFormat("Adding CDN application for site '{0}'", siteName); cdnApplication = adminSite.Applications.Add("/cdn/" + siteName, Path.Combine(sitePath, "cdn")); cdnApplication.ApplicationPoolName = appPool.Name; } } else { if (cdnApplication != null) { _logger.InfoFormat("Removing CDN application for site '{0}'", siteName); adminSite.Applications.Remove(cdnApplication); } } }
public static async Task StopAndWait(this IIS.ApplicationPool appPool) { appPool.Stop(); await appPool.WaitForState(IIS.ObjectState.Stopped); }
internal abstract Task <bool> GetPoolStateAsync(ApplicationPool pool);
internal virtual void Stop(ApplicationPool applicationPool) { }
internal abstract Task<bool> GetPoolStateAsync(ApplicationPool pool);
public PoolDesiredState(ApplicationPool iisPoolObject, IISCodeGenerator.IisPoolAndSitesOptions iisOptions) { Initialize(iisPoolObject, iisOptions); }
void SetApplicationPoolIdentity(ApplicationPool pool) { if (ProcessModelIdentityType != ProcessModelIdentityType.SpecificUser && pool.ProcessModel.IdentityType == ProcessModelIdentityType) return; pool.ProcessModel.IdentityType = ProcessModelIdentityType; var identityUsername = ProcessModelIdentityType.ToString(); if (ProcessModelIdentityType == ProcessModelIdentityType.SpecificUser) { pool.ProcessModel.UserName = ProcessModelUsername; pool.ProcessModel.Password = ProcessModelPassword; identityUsername = ProcessModelUsername; } LogIis("[iis7] Set process model identity '{0}'", identityUsername); }
internal ApplicationPoolFailure(ApplicationPool parent) : this(null, parent) { }
/// <summary> /// Initializes a new instance of the <see cref="IisApplicationPool"/> class. /// </summary> /// <param name="pool"> /// The pool. /// </param> public IisApplicationPool(ApplicationPool pool) { this.serverManager = new ServerManager(); this.iisPool = pool; this.Name = pool.Name; }
internal ApplicationPoolCpu(ApplicationPool parent) : this(null, parent) { }
public static async Task WaitForState(this IIS.ApplicationPool appPool, IIS.ObjectState state) { await WaitForState(() => appPool.State, state); }
private bool AppPoolExists() { this.pool = this.iisServerManager.ApplicationPools[this.Name.Get(this.ActivityContext)]; return this.pool != null; }
internal override async Task<bool> GetPoolStateAsync(ApplicationPool pool) { return true; }
internal override bool GetPoolState(ApplicationPool pool) { return(true); }
public async Task LoadAsync() { SortedDictionary<string, List<string>> variables = null; if (Credentials == null) { var lines = File.ReadAllLines("jws.conf"); variables = new SortedDictionary<string, List<string>>(); foreach (var line in lines) { var index = line.IndexOf('#'); var content = index == -1 ? line : line.Substring(0, index); var parts = content.Split(new[] { '=' }, StringSplitOptions.RemoveEmptyEntries); if (parts.Length != 2) { continue; } var key = parts[0].Trim().ToLowerInvariant(); var value = parts[1].Trim(); if (variables.ContainsKey(key)) { variables[key].Add(value); } else { variables.Add(key, new List<string> { value }); } } } else { using (var client = GetClient()) { HttpResponseMessage response = await client.GetAsync("api/server/"); if (response.IsSuccessStatusCode) { variables = (SortedDictionary<string, List<string>>)await response.Content.ReadAsAsync(typeof(SortedDictionary<string, List<string>>)); } } } var newPool = new ApplicationPool(null, ApplicationPools); newPool.Name = "DefaultAppPool"; newPool.ManagedRuntimeVersion = variables.Load(new List<string> { "v2.0" }, "runtime")[0]; newPool.ProcessModel.MaxProcesses = long.Parse(variables.Load(new List<string> { "1" }, "httpd.processes")[0]); newPool.ProcessModel.UserName = variables.Load(new List<string> { string.Empty }, "httpd.user")[0]; newPool.ProcessModel.IdentityType = ProcessModelIdentityType.SpecificUser; ApplicationPools.Add(newPool); SiteFolder = variables.Load(new List<string> { "siteconf" }, "siteconfigdir")[0]; LogFolder = variables.Load(new List<string> { "log" }, "sitelogdir")[0]; _certificateCache = variables.Load(new List<string> { string.Empty }, "certificatefile")[0]; _keyCache = variables.Load(new List<string> { string.Empty }, "certificatekeyfile")[0]; IEnumerable<string> sites = null; if (Credentials == null) { sites = Directory.GetFiles(SiteFolder).Where(name => !name.Contains("_")); } else { using (var client = GetClient()) { HttpResponseMessage response = await client.GetAsync("api/site/"); if (response.IsSuccessStatusCode) { sites = (List<string>)await response.Content.ReadAsAsync(typeof(List<string>)); } } } long count = 0; Debug.Assert(sites != null, "sites != null"); foreach (var file in sites) { var site = Credentials == null ? new Site(Sites) { Name = Path.GetFileName(file), Id = count } : new Site(Sites) { Name = file, Id = count }; Sites.Add(site); count = await LoadAsync(site, count, file, SiteFolder); } Extra = variables; }
private void Create() { if (this.AppPoolExists()) { if (!this.Force) { Log.LogError(string.Format(CultureInfo.CurrentCulture, "ApplicationPool: {0} already exists on: {1}", this.Name, this.MachineName)); return; } this.LogTaskMessage(string.Format(CultureInfo.CurrentCulture, "Deleting ApplicationPool: {0} on: {1}", this.Name, this.MachineName)); this.iisServerManager.ApplicationPools.Remove(this.pool); this.iisServerManager.CommitChanges(); } this.LogTaskMessage(string.Format(CultureInfo.CurrentCulture, "Creating ApplicationPool: {0} on: {1}", this.Name, this.MachineName)); this.pool = this.iisServerManager.ApplicationPools.Add(this.Name); if (!this.UseDefaultIdentity) { if (this.IdentityType == "SpecificUser" && (string.IsNullOrEmpty(this.PoolIdentity) || string.IsNullOrEmpty(this.IdentityPassword))) { Log.LogError("PoolIdentity and PoolPassword must be specified if the IdentityType is SpecificUser"); return; } this.LogTaskMessage(MessageImportance.Low, string.Format(CultureInfo.CurrentCulture, "Setting ProcessModelIdentityType to: {0}", this.IdentityType)); this.pool.ProcessModel.IdentityType = this.processModelType; } this.LogTaskMessage(MessageImportance.Low, string.Format(CultureInfo.CurrentCulture, "Setting ManagedPipelineMode to: {0}", this.PipelineMode)); this.pool.ManagedPipelineMode = this.managedPM; if (this.IdentityType == "SpecificUser") { this.pool.ProcessModel.UserName = this.PoolIdentity; this.pool.ProcessModel.Password = this.IdentityPassword; } this.SetCommonInfo(); this.iisServerManager.CommitChanges(); }
internal override async Task <bool> GetPoolStateAsync(ApplicationPool pool) { return(true); }
public static void WaitForState(this IIS.ApplicationPool appPool, IIS.ObjectState state) { new PollingWait(() => { }, () => appPool.State == state).Invoke(); }
internal virtual void Recycle(ApplicationPool applicationPool) { }
public static void StopAndWait(this IIS.ApplicationPool appPool) { var wait = new PollingWait(() => appPool.Stop(), () => appPool.State == IIS.ObjectState.Stopped); wait.Invoke(); }
internal abstract bool GetPoolState(ApplicationPool pool);
//todo: there is quite a bit going on in here...this is going to need to be looked at... private void ExecuteOperation(ApplicationPool appPool, DeploymentResult result) { switch (Operation) { case Iis7ApplicationPoolOperation.StopApplicationPool: if (appPool == null) { result.AddAlert(ApplicationPoolDoesNotExistError); } else if (appPool.CanBeStopped()) { CheckForElevatedPrivileges(appPool.StopAndWaitForCompletion); result.AddGood("Application Pool '{0}' stopped.".FormatWith(ApplicationPool)); } else { result.AddNote("Application Pool '{0}' is not running.".FormatWith(ApplicationPool)); } break; case Iis7ApplicationPoolOperation.StartApplicationPool: if (appPool == null) { throw new InvalidOperationException(ApplicationPoolDoesNotExistError); } else if (appPool.CanBeStarted()) { IisUtility.WaitForIisToCompleteAnyOperations(); CheckForElevatedPrivileges(appPool.StartAndWaitForCompletion); result.AddGood("Application Pool '{0}' started.".FormatWith(ApplicationPool)); } else { result.AddGood("Application Pool '{0}' is already running.".FormatWith(ApplicationPool)); } break; } }
private static Array InventoryWorkerProcesses(ApplicationPool AppPool, bool bVerboseInventory) { List<AppPoolWorkerProcesses> listAppPoolWorkerProcesses = new List<AppPoolWorkerProcesses>(); // Skip, verbose inventory is not wanted. if (bVerboseInventory == false) return listAppPoolWorkerProcesses.ToArray(); foreach (var WorkerProcess in AppPool.WorkerProcesses) { Array temp_AppPoolWorkerProcessAppDomains = InventoryWPAppDomains(WorkerProcess.ApplicationDomains, AppPool, bVerboseInventory); listAppPoolWorkerProcesses.Add(new AppPoolWorkerProcesses(WorkerProcess.AppPoolName, WorkerProcess.IsLocallyStored, WorkerProcess.State.ToString(), temp_AppPoolWorkerProcessAppDomains)); } Array ArrWorkerProcesses = listAppPoolWorkerProcesses.ToArray(); return ArrWorkerProcesses; }
public static async Task StartAndWait(this IIS.ApplicationPool appPool) { appPool.Start(); await WaitForState(() => appPool.State, IIS.ObjectState.Started); }
private static IISSiteStatus GetStatus(ApplicationPool applicationPool) { try { return GetStatus(applicationPool.State); } catch(Exception) { return IISSiteStatus.Unkown; } }
private static Array InventoryWPAppDomains(ApplicationDomainCollection WPAppDomains, ApplicationPool AppPool, bool bVerboseInventory) { List<AppPoolWPAppDomains> listAppPoolWPApplicationDomains = new List<AppPoolWPAppDomains>(); // Skip, verbose inventory is not wanted. if (bVerboseInventory == false) return listAppPoolWPApplicationDomains.ToArray(); foreach (var ApplicationDomain in WPAppDomains) { //Array ArrWorkerProcesses = InventoryWorkerProcesses(AppPool, bVerboseInventory); Array ArrWorkerProcesses = new Array[] { null }; listAppPoolWPApplicationDomains.Add(new AppPoolWPAppDomains(ApplicationDomain.Id, ApplicationDomain.Idle, ApplicationDomain.IsLocallyStored, ApplicationDomain.PhysicalPath, ApplicationDomain.VirtualPath, ArrWorkerProcesses)); } Array ArrWPAppDomains = listAppPoolWPApplicationDomains.ToArray(); return ArrWPAppDomains; }
public async Task LoadAsync() { SortedDictionary <string, List <string> > variables = null; if (Credentials == null) { var lines = File.ReadAllLines("jws.conf"); variables = new SortedDictionary <string, List <string> >(); foreach (var line in lines) { var index = line.IndexOf('#'); var content = index == -1 ? line : line.Substring(0, index); var parts = content.Split(new[] { '=' }, StringSplitOptions.RemoveEmptyEntries); if (parts.Length != 2) { continue; } var key = parts[0].Trim().ToLowerInvariant(); var value = parts[1].Trim(); if (variables.ContainsKey(key)) { variables[key].Add(value); } else { variables.Add(key, new List <string> { value }); } } } else { using (var client = GetClient()) { HttpResponseMessage response = await client.GetAsync("api/server/"); if (response.IsSuccessStatusCode) { variables = (SortedDictionary <string, List <string> >) await response.Content.ReadAsAsync(typeof(SortedDictionary <string, List <string> >)); } } } var newPool = new ApplicationPool(null, ApplicationPools); newPool.Name = "DefaultAppPool"; newPool.ManagedRuntimeVersion = variables.Load(new List <string> { "v2.0" }, "runtime")[0]; newPool.ProcessModel.MaxProcesses = long.Parse(variables.Load(new List <string> { "1" }, "httpd.processes")[0]); newPool.ProcessModel.UserName = variables.Load(new List <string> { string.Empty }, "httpd.user")[0]; newPool.ProcessModel.IdentityType = ProcessModelIdentityType.SpecificUser; ApplicationPools.Add(newPool); SiteFolder = variables.Load(new List <string> { "siteconf" }, "siteconfigdir")[0]; LogFolder = variables.Load(new List <string> { "log" }, "sitelogdir")[0]; _certificateCache = variables.Load(new List <string> { string.Empty }, "certificatefile")[0]; _keyCache = variables.Load(new List <string> { string.Empty }, "certificatekeyfile")[0]; IEnumerable <string> sites = null; if (Credentials == null) { sites = Directory.GetFiles(SiteFolder).Where(name => !name.Contains("_")); } else { using (var client = GetClient()) { HttpResponseMessage response = await client.GetAsync("api/site/"); if (response.IsSuccessStatusCode) { sites = (List <string>) await response.Content.ReadAsAsync(typeof(List <string>)); } } } long count = 0; Debug.Assert(sites != null, "sites != null"); foreach (var file in sites) { var site = Credentials == null ? new Site(Sites) { Name = Path.GetFileName(file), Id = count } : new Site(Sites) { Name = file, Id = count }; Sites.Add(site); count = await LoadAsync(site, count, file, SiteFolder); } Extra = variables; }
private bool AppPoolExists() { this.pool = this.iisServerManager.ApplicationPools[this.Name]; return this.pool != null; }
private void loadVirtualDirectory() { using (var iis = ServerManager.OpenRemote("localhost")) { var site = iis.Sites[WebSiteName]; var appPath = "/" + VirtualDirectory; _application = site.Applications[appPath]; _virtualDirectory = _application.VirtualDirectories["/"]; _appPool = iis.ApplicationPools[_application.ApplicationPoolName]; } }