Revert "Add retries to selfhost deployer (#13063)"
- per @Tratcher this change is not needed in 'master'
This reverts commit d19093ecbb.
This commit is contained in:
parent
339c720d86
commit
24fe524029
|
|
@ -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.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting
|
||||||
private static readonly Regex NowListeningRegex = new Regex(@"^\s*Now listening on: (?<url>.*)$");
|
private static readonly Regex NowListeningRegex = new Regex(@"^\s*Now listening on: (?<url>.*)$");
|
||||||
private const string ApplicationStartedMessage = "Application started. Press Ctrl+C to shut down.";
|
private const string ApplicationStartedMessage = "Application started. Press Ctrl+C to shut down.";
|
||||||
|
|
||||||
private const int RetryCount = 5;
|
|
||||||
public Process HostProcess { get; private set; }
|
public Process HostProcess { get; private set; }
|
||||||
|
|
||||||
public SelfHostDeployer(DeploymentParameters deploymentParameters, ILoggerFactory loggerFactory)
|
public SelfHostDeployer(DeploymentParameters deploymentParameters, ILoggerFactory loggerFactory)
|
||||||
|
|
@ -56,33 +55,23 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting
|
||||||
DotnetPublish();
|
DotnetPublish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var hintUrl = TestUriHelper.BuildTestUri(
|
||||||
|
DeploymentParameters.ServerType,
|
||||||
|
DeploymentParameters.Scheme,
|
||||||
|
DeploymentParameters.ApplicationBaseUriHint,
|
||||||
|
DeploymentParameters.StatusMessagesEnabled);
|
||||||
|
|
||||||
// Launch the host process.
|
// Launch the host process.
|
||||||
for (var i = 0; i < RetryCount; i++)
|
var (actualUrl, hostExitToken) = await StartSelfHostAsync(hintUrl);
|
||||||
{
|
|
||||||
var hintUrl = TestUriHelper.BuildTestUri(
|
|
||||||
DeploymentParameters.ServerType,
|
|
||||||
DeploymentParameters.Scheme,
|
|
||||||
DeploymentParameters.ApplicationBaseUriHint,
|
|
||||||
DeploymentParameters.StatusMessagesEnabled);
|
|
||||||
var (actualUrl, hostExitToken) = await StartSelfHostAsync(hintUrl);
|
|
||||||
|
|
||||||
if (DeploymentParameters.ServerType == ServerType.HttpSys && hostExitToken.IsCancellationRequested)
|
Logger.LogInformation("Application ready at URL: {appUrl}", actualUrl);
|
||||||
{
|
|
||||||
// Retry HttpSys deployments due to port conflicts.
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Logger.LogInformation("Application ready at URL: {appUrl}", actualUrl);
|
return new DeploymentResult(
|
||||||
|
LoggerFactory,
|
||||||
return new DeploymentResult(
|
DeploymentParameters,
|
||||||
LoggerFactory,
|
applicationBaseUri: actualUrl.ToString(),
|
||||||
DeploymentParameters,
|
contentRoot: DeploymentParameters.PublishApplicationBeforeDeployment ? DeploymentParameters.PublishedApplicationRootPath : DeploymentParameters.ApplicationPath,
|
||||||
applicationBaseUri: actualUrl.ToString(),
|
hostShutdownToken: hostExitToken);
|
||||||
contentRoot: DeploymentParameters.PublishApplicationBeforeDeployment ? DeploymentParameters.PublishedApplicationRootPath : DeploymentParameters.ApplicationPath,
|
|
||||||
hostShutdownToken: hostExitToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new Exception($"Failed to start Self hosted application after {RetryCount} retries.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -176,6 +165,8 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting
|
||||||
Logger.LogInformation("host process ID {pid} shut down", HostProcess.Id);
|
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
|
// 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);
|
TriggerHostShutdown(hostExitTokenSource);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -187,6 +178,7 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting
|
||||||
{
|
{
|
||||||
Logger.LogError("Error occurred while starting the process. Exception: {exception}", ex.ToString());
|
Logger.LogError("Error occurred while starting the process. Exception: {exception}", ex.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HostProcess.HasExited)
|
if (HostProcess.HasExited)
|
||||||
{
|
{
|
||||||
Logger.LogError("Host process {processName} {pid} exited with code {exitCode} or failed to start.", startInfo.FileName, HostProcess.Id, HostProcess.ExitCode);
|
Logger.LogError("Host process {processName} {pid} exited with code {exitCode} or failed to start.", startInfo.FileName, HostProcess.Id, HostProcess.ExitCode);
|
||||||
|
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
@ECHO OFF
|
|
||||||
SET RepoRoot=%~dp0..\..
|
|
||||||
%RepoRoot%\build.cmd -projects %~dp0**\*.*proj %*
|
|
||||||
Loading…
Reference in New Issue