Add missing curly bracket
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
using System.Net;
|
using FluentValidation;
|
||||||
using FluentValidation;
|
|
||||||
using UmlautAdaptarr.Options.ArrOptions.InstanceOptions;
|
using UmlautAdaptarr.Options.ArrOptions.InstanceOptions;
|
||||||
|
|
||||||
namespace UmlautAdaptarr.Validator;
|
namespace UmlautAdaptarr.Validator;
|
||||||
@@ -36,36 +35,37 @@ public class GlobalInstanceOptionsValidator : AbstractValidator<GlobalInstanceOp
|
|||||||
&& (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps);
|
&& (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task<bool> BeReachable(GlobalInstanceOptions opts, CancellationToken cancellationToken)
|
private static async Task<bool> BeReachable(GlobalInstanceOptions opts, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var endTime = DateTime.Now.AddMinutes(3);
|
var endTime = DateTime.Now.AddMinutes(3);
|
||||||
var reachable = false;
|
var reachable = false;
|
||||||
var url = $"{opts.Host}/api?apikey={opts.ApiKey}";
|
var url = $"{opts.Host}/api?apikey={opts.ApiKey}";
|
||||||
|
|
||||||
while (DateTime.Now < endTime)
|
while (DateTime.Now < endTime)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var response = await httpClient.GetAsync(url, cancellationToken);
|
using var response = await httpClient.GetAsync(url, cancellationToken);
|
||||||
if (response.IsSuccessStatusCode)
|
if (response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
reachable = true;
|
reachable = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Reachable check got unexpected status code {response.StatusCode}.");
|
Console.WriteLine($"Reachable check got unexpected status code {response.StatusCode}.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine(ex.Message);
|
Console.WriteLine(ex.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for 15 seconds for next try
|
// Wait for 15 seconds for next try
|
||||||
Console.WriteLine($"The URL \"{opts.Host}/api?apikey=[REDACTED]\" is not reachable. Next attempt in 15 seconds...");
|
Console.WriteLine($"The URL \"{opts.Host}/api?apikey=[REDACTED]\" is not reachable. Next attempt in 15 seconds...");
|
||||||
Thread.Sleep(15000);
|
Thread.Sleep(15000);
|
||||||
}
|
}
|
||||||
|
|
||||||
return reachable;
|
return reachable;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user