From 24fe524029d1f9a6edbabdd3dca657270f8b024f Mon Sep 17 00:00:00 2001 From: Doug Bunting <6431421+dougbu@users.noreply.github.com> Date: Fri, 20 Sep 2019 16:48:14 -0700 Subject: [PATCH] Revert "Add retries to selfhost deployer (#13063)" - per @Tratcher this change is not needed in 'master' This reverts commit d19093ecbb91a0dd1d7b2cb50234ec590baa730c. --- .../src/Deployers/NginxDeployer.cs | 2 +- .../src/Deployers/SelfHostDeployer.cs | 42 ++++++++----------- src/Hosting/build.cmd | 3 -- 3 files changed, 18 insertions(+), 29 deletions(-) delete mode 100644 src/Hosting/build.cmd diff --git a/src/Hosting/Server.IntegrationTesting/src/Deployers/NginxDeployer.cs b/src/Hosting/Server.IntegrationTesting/src/Deployers/NginxDeployer.cs index d5c0dc02ca..262ff80ce8 100644 --- a/src/Hosting/Server.IntegrationTesting/src/Deployers/NginxDeployer.cs +++ b/src/Hosting/Server.IntegrationTesting/src/Deployers/NginxDeployer.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; diff --git a/src/Hosting/Server.IntegrationTesting/src/Deployers/SelfHostDeployer.cs b/src/Hosting/Server.IntegrationTesting/src/Deployers/SelfHostDeployer.cs index 06923f7c46..e6e724c98c 100644 --- a/src/Hosting/Server.IntegrationTesting/src/Deployers/SelfHostDeployer.cs +++ b/src/Hosting/Server.IntegrationTesting/src/Deployers/SelfHostDeployer.cs @@ -22,7 +22,6 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting private static readonly Regex NowListeningRegex = new Regex(@"^\s*Now listening on: (?.*)$"); private const string ApplicationStartedMessage = "Application started. Press Ctrl+C to shut down."; - private const int RetryCount = 5; public Process HostProcess { get; private set; } public SelfHostDeployer(DeploymentParameters deploymentParameters, ILoggerFactory loggerFactory) @@ -56,33 +55,23 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting DotnetPublish(); } + var hintUrl = TestUriHelper.BuildTestUri( + DeploymentParameters.ServerType, + DeploymentParameters.Scheme, + DeploymentParameters.ApplicationBaseUriHint, + DeploymentParameters.StatusMessagesEnabled); + // Launch the host process. - for (var i = 0; i < RetryCount; i++) - { - var hintUrl = TestUriHelper.BuildTestUri( - DeploymentParameters.ServerType, - DeploymentParameters.Scheme, - DeploymentParameters.ApplicationBaseUriHint, - DeploymentParameters.StatusMessagesEnabled); - var (actualUrl, hostExitToken) = await StartSelfHostAsync(hintUrl); + var (actualUrl, hostExitToken) = await StartSelfHostAsync(hintUrl); - if (DeploymentParameters.ServerType == ServerType.HttpSys && hostExitToken.IsCancellationRequested) - { - // Retry HttpSys deployments due to port conflicts. - continue; - } + Logger.LogInformation("Application ready at URL: {appUrl}", actualUrl); - Logger.LogInformation("Application ready at URL: {appUrl}", actualUrl); - - return new DeploymentResult( - LoggerFactory, - DeploymentParameters, - applicationBaseUri: actualUrl.ToString(), - contentRoot: DeploymentParameters.PublishApplicationBeforeDeployment ? DeploymentParameters.PublishedApplicationRootPath : DeploymentParameters.ApplicationPath, - hostShutdownToken: hostExitToken); - } - - throw new Exception($"Failed to start Self hosted application after {RetryCount} retries."); + return new DeploymentResult( + LoggerFactory, + DeploymentParameters, + applicationBaseUri: actualUrl.ToString(), + contentRoot: DeploymentParameters.PublishApplicationBeforeDeployment ? DeploymentParameters.PublishedApplicationRootPath : DeploymentParameters.ApplicationPath, + hostShutdownToken: hostExitToken); } } @@ -176,6 +165,8 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting Logger.LogInformation("host process ID {pid} shut down", HostProcess.Id); // If TrySetResult was called above, this will just silently fail to set the new state, which is what we want + started.TrySetException(new Exception($"Command exited unexpectedly with exit code: {HostProcess.ExitCode}")); + TriggerHostShutdown(hostExitTokenSource); }; @@ -187,6 +178,7 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting { Logger.LogError("Error occurred while starting the process. Exception: {exception}", ex.ToString()); } + if (HostProcess.HasExited) { Logger.LogError("Host process {processName} {pid} exited with code {exitCode} or failed to start.", startInfo.FileName, HostProcess.Id, HostProcess.ExitCode); diff --git a/src/Hosting/build.cmd b/src/Hosting/build.cmd deleted file mode 100644 index 2406296662..0000000000 --- a/src/Hosting/build.cmd +++ /dev/null @@ -1,3 +0,0 @@ -@ECHO OFF -SET RepoRoot=%~dp0..\.. -%RepoRoot%\build.cmd -projects %~dp0**\*.*proj %*