Stop site and app pool before restoring config (#1112)
This commit is contained in:
parent
7d641f8796
commit
7a4a945fd6
|
|
@ -65,7 +65,7 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting
|
|||
}
|
||||
AddTemporaryAppHostConfig();
|
||||
|
||||
var apppool = ConfigureAppPool(contentRoot);
|
||||
ConfigureAppPool(contentRoot);
|
||||
|
||||
ConfigureSite(contentRoot, port);
|
||||
|
||||
|
|
@ -73,11 +73,11 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting
|
|||
|
||||
_serverManager.CommitChanges();
|
||||
|
||||
await WaitUntilSiteStarted(apppool);
|
||||
await WaitUntilSiteStarted();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task WaitUntilSiteStarted(ApplicationPool appPool)
|
||||
private async Task WaitUntilSiteStarted()
|
||||
{
|
||||
var sw = Stopwatch.StartNew();
|
||||
|
||||
|
|
@ -85,12 +85,19 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting
|
|||
{
|
||||
try
|
||||
{
|
||||
var site = _serverManager.Sites.FirstOrDefault(s => s.Name.Equals(WebSiteName));
|
||||
var serverManager = new ServerManager();
|
||||
var appPool = serverManager.ApplicationPools.FirstOrDefault(s => s.Name.Equals(AppPoolName));
|
||||
var site = serverManager.Sites.FirstOrDefault(s => s.Name.Equals(WebSiteName));
|
||||
|
||||
if (site.State == ObjectState.Started)
|
||||
{
|
||||
_logger.LogInformation($"Site {WebSiteName} has started.");
|
||||
return;
|
||||
var workerProcess = appPool.WorkerProcesses.SingleOrDefault();
|
||||
if (workerProcess != null)
|
||||
{
|
||||
HostProcess = Process.GetProcessById(workerProcess.ProcessId);
|
||||
_logger.LogInformation($"Site {WebSiteName} has started.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (site.State != ObjectState.Starting)
|
||||
{
|
||||
|
|
@ -122,11 +129,15 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting
|
|||
return;
|
||||
}
|
||||
|
||||
RestoreAppHostConfig();
|
||||
StopSite();
|
||||
|
||||
StopAppPool();
|
||||
|
||||
_serverManager.CommitChanges();
|
||||
|
||||
await WaitUntilSiteStopped();
|
||||
|
||||
RestoreAppHostConfig();
|
||||
}
|
||||
|
||||
private async Task WaitUntilSiteStopped()
|
||||
|
|
@ -145,8 +156,11 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting
|
|||
{
|
||||
if (site.State == ObjectState.Stopped)
|
||||
{
|
||||
_logger.LogInformation($"Site {WebSiteName} has stopped successfully.");
|
||||
return;
|
||||
if (HostProcess.HasExited)
|
||||
{
|
||||
_logger.LogInformation($"Site {WebSiteName} has stopped successfully.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (COMException)
|
||||
|
|
@ -275,6 +289,20 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting
|
|||
return config;
|
||||
}
|
||||
|
||||
private void StopSite()
|
||||
{
|
||||
var site = _serverManager.Sites.Where(sites => sites.Name == WebSiteName).SingleOrDefault();
|
||||
|
||||
site.Stop();
|
||||
}
|
||||
|
||||
private void StopAppPool()
|
||||
{
|
||||
var appPool = _serverManager.ApplicationPools.Where(pool => pool.Name == AppPoolName).SingleOrDefault();
|
||||
|
||||
appPool.Stop();
|
||||
}
|
||||
|
||||
private void SetGlobalModuleSection(Configuration config, string dllRoot)
|
||||
{
|
||||
var ancmFile = GetAncmLocation(dllRoot);
|
||||
|
|
|
|||
|
|
@ -106,7 +106,11 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS
|
|||
5,
|
||||
200);
|
||||
|
||||
Logger.LogInformation($"Found debug log file: {file}");
|
||||
if (arr.Length == 0)
|
||||
{
|
||||
Logger.LogWarning($"{file} is empty.");
|
||||
}
|
||||
|
||||
foreach (var line in arr)
|
||||
{
|
||||
Logger.LogInformation(line);
|
||||
|
|
|
|||
Loading…
Reference in New Issue