Skip to content

Commit acc9c4b

Browse files
committed
Undo stop changes
1 parent 31471ad commit acc9c4b

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

src/Servers/IIS/IntegrationTesting.IIS/src/IISDeployer.cs

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -361,27 +361,26 @@ private void Stop()
361361
{
362362
RetryServerManagerAction(serverManager =>
363363
{
364-
foreach (var site in serverManager.Sites)
364+
var site = serverManager.Sites.SingleOrDefault();
365+
if (site == null)
365366
{
366-
if (site.State != ObjectState.Stopped && site.State != ObjectState.Stopping)
367-
{
368-
var state = site.Stop();
369-
Logger.LogInformation($"Stopping site, state: {state}");
370-
}
367+
throw new InvalidOperationException("Site not found");
371368
}
372369

373-
foreach (var appPool in serverManager.ApplicationPools)
370+
if (site.State != ObjectState.Stopped && site.State != ObjectState.Stopping)
374371
{
375372
var state = site.Stop();
376373
Logger.LogInformation($"Stopping site, state: {state}");
374+
377375
if (appPool.State != ObjectState.Stopped && appPool.State != ObjectState.Stopping)
378376
{
379377
var state = appPool.Stop();
380378
Logger.LogInformation($"Stopping pool, state: {state}");
381379
}
382380
}
383381

384-
foreach (var site in serverManager.Sites)
382+
var appPool = serverManager.ApplicationPools.SingleOrDefault();
383+
if (appPool == null)
385384
{
386385
throw new InvalidOperationException("Application pool not found");
387386
}
@@ -400,16 +399,14 @@ private void Stop()
400399

401400
try
402401
{
403-
foreach (var appPool in serverManager.ApplicationPools)
402+
if (appPool.WorkerProcesses != null &&
403+
appPool.WorkerProcesses.Any(wp =>
404+
wp.State == WorkerProcessState.Running ||
405+
wp.State == WorkerProcessState.Stopping))
404406
{
405-
if (appPool.WorkerProcesses != null &&
406-
appPool.WorkerProcesses.Any(wp =>
407-
wp.State == WorkerProcessState.Running ||
408-
wp.State == WorkerProcessState.Stopping))
409-
{
410-
throw new InvalidOperationException("WorkerProcess not stopped yet");
411-
}
407+
throw new InvalidOperationException("WorkerProcess not stopped yet");
412408
}
409+
413410
}
414411
// If WAS was stopped for some reason appPool.WorkerProcesses
415412
// would throw UnauthorizedAccessException.

0 commit comments

Comments
 (0)