Skip to content

Commit 6a7d2c9

Browse files
committed
Undo stop changes
1 parent b746f7b commit 6a7d2c9

File tree

1 file changed

+26
-25
lines changed

1 file changed

+26
-25
lines changed

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

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -361,44 +361,45 @@ 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
{
375-
if (appPool.State != ObjectState.Stopped && appPool.State != ObjectState.Stopping)
376-
{
377-
var state = appPool.Stop();
378-
Logger.LogInformation($"Stopping pool, state: {state}");
379-
}
372+
var state = site.Stop();
373+
Logger.LogInformation($"Stopping site, state: {state}");
380374
}
381375

382-
foreach (var site in serverManager.Sites)
376+
var appPool = serverManager.ApplicationPools.SingleOrDefault();
377+
if (appPool == null)
383378
{
384-
if (site.State != ObjectState.Stopped)
385-
{
386-
throw new InvalidOperationException($"Site {site.Name} not stopped yet");
387-
}
379+
throw new InvalidOperationException("Application pool not found");
380+
}
381+
382+
if (appPool.State != ObjectState.Stopped && appPool.State != ObjectState.Stopping)
383+
{
384+
var state = appPool.Stop();
385+
Logger.LogInformation($"Stopping pool, state: {state}");
386+
}
387+
388+
if (site.State != ObjectState.Stopped)
389+
{
390+
throw new InvalidOperationException("Site not stopped yet");
388391
}
389392

390393
try
391394
{
392-
foreach (var appPool in serverManager.ApplicationPools)
395+
if (appPool.WorkerProcesses != null &&
396+
appPool.WorkerProcesses.Any(wp =>
397+
wp.State == WorkerProcessState.Running ||
398+
wp.State == WorkerProcessState.Stopping))
393399
{
394-
if (appPool.WorkerProcesses != null &&
395-
appPool.WorkerProcesses.Any(wp =>
396-
wp.State == WorkerProcessState.Running ||
397-
wp.State == WorkerProcessState.Stopping))
398-
{
399-
throw new InvalidOperationException("WorkerProcess not stopped yet");
400-
}
400+
throw new InvalidOperationException("WorkerProcess not stopped yet");
401401
}
402+
402403
}
403404
// If WAS was stopped for some reason appPool.WorkerProcesses
404405
// would throw UnauthorizedAccessException.

0 commit comments

Comments
 (0)