Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ private async Task BuildBinariesAsync(EventContext telemetryContext, Cancellatio
IApiClientManager clientManager = this.Dependencies.GetService<IApiClientManager>();
var apiClient = clientManager.GetOrCreateApiClient(IPAddress.Loopback.ToString(), IPAddress.Loopback);

await this.WaitForApiServerReadyAsync(apiClient, cancellationToken);
Comment thread
saibulusu marked this conversation as resolved.
Outdated

HttpResponseMessage response = await apiClient.GetStateAsync(nameof(this.NpbBuildState), cancellationToken)
.ConfigureAwait(false);

Expand All @@ -172,6 +174,31 @@ await this.LogProcessDetailsAsync(makeProcess, telemetryContext)
}
}

private async Task WaitForApiServerReadyAsync(IApiClient apiClient, CancellationToken cancellationToken, int timeoutSeconds = 30)
{
var timeout = TimeSpan.FromSeconds(timeoutSeconds);
var start = DateTime.UtcNow;

while (DateTime.UtcNow - start < timeout)
{
try
{
var response = await apiClient.GetHeartbeatAsync(cancellationToken);
if (response.IsSuccessStatusCode)
{
return;
}
}
catch
{
}

await Task.Delay(1000, cancellationToken);
}

throw new Exception("API server did not become ready in time.");
}

private async Task CheckDistroSupportAsync(EventContext telemetryContext, CancellationToken cancellationToken)
{
if (this.Platform == PlatformID.Unix)
Expand Down
Loading