Merge branch 'develop' of https://github.com/PCJones/UmlautAdaptarr into develop
This commit is contained in:
@@ -68,7 +68,7 @@ public static class ServicesExtensions
|
||||
Console.WriteLine(($"Property {failure.PropertyName } failed validation. Error was: {failure.ErrorMessage}"));
|
||||
}
|
||||
|
||||
throw new Exception("Please fix your environment variables and then Start UmlautAdaptarr again");
|
||||
throw new Exception("Please fix cour environment variables and then Start UmlautAdaptarr again");
|
||||
}
|
||||
|
||||
var instanceState = (bool)(typeof(TOptions).GetProperty("Enabled")?.GetValue(option, null) ?? false);
|
||||
|
||||
@@ -36,37 +36,36 @@ public class GlobalInstanceOptionsValidator : AbstractValidator<GlobalInstanceOp
|
||||
&& (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps);
|
||||
}
|
||||
|
||||
private static async Task<bool> BeReachable(GlobalInstanceOptions opts, CancellationToken cancellationToken)
|
||||
{
|
||||
var endTime = DateTime.Now.AddMinutes(3);
|
||||
var reachable = false;
|
||||
var url = $"{opts.Host}/api?apikey={opts.ApiKey}";
|
||||
private static async Task<bool> BeReachable(GlobalInstanceOptions opts, CancellationToken cancellationToken)
|
||||
{
|
||||
var endTime = DateTime.Now.AddMinutes(3);
|
||||
var reachable = false;
|
||||
var url = $"{opts.Host}/api?apikey={opts.ApiKey}";
|
||||
|
||||
while (DateTime.Now < endTime)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var response = await httpClient.GetAsync(url, cancellationToken);
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
reachable = true;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"Reachable check got unexpected status code {response.StatusCode}.");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
}
|
||||
while (DateTime.Now < endTime)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var response = await httpClient.GetAsync(url, cancellationToken);
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
reachable = true;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"Reachable check got unexpected status code {response.StatusCode}.");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
}
|
||||
|
||||
// Wait for 15 seconds for next try
|
||||
Console.WriteLine($"The URL \"{opts.Host}/api?apikey=[REDACTED]\" is not reachable. Next attempt in 15 seconds...");
|
||||
Thread.Sleep(15000);
|
||||
}
|
||||
// Wait for 15 seconds for next try
|
||||
Console.WriteLine($"The URL \"{opts.Host}/api?apikey=[REDACTED]\" is not reachable. Next attempt in 15 seconds...");
|
||||
Thread.Sleep(15000);
|
||||
}
|
||||
|
||||
return reachable;
|
||||
}
|
||||
return reachable;
|
||||
}
|
||||
Reference in New Issue
Block a user