Implemented container helper status checked. Started implementing container helper ui. Improved update modal
This commit is contained in:
@@ -13,6 +13,23 @@ public class ContainerHelperService
|
||||
HttpClientFactory = httpClientFactory;
|
||||
}
|
||||
|
||||
public async Task<bool> CheckConnectionAsync()
|
||||
{
|
||||
var client = HttpClientFactory.CreateClient("ContainerHelper");
|
||||
|
||||
try
|
||||
{
|
||||
var response = await client.GetAsync("api/ping");
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public async IAsyncEnumerable<RebuildEvent> RebuildAsync()
|
||||
{
|
||||
var options = new JsonSerializerOptions()
|
||||
@@ -29,6 +46,7 @@ public class ContainerHelperService
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
var responseText = await response.Content.ReadAsStringAsync();
|
||||
|
||||
yield return new RebuildEvent()
|
||||
{
|
||||
Type = RebuildEventType.Failed,
|
||||
@@ -56,6 +74,11 @@ public class ContainerHelperService
|
||||
var deserializedData = JsonSerializer.Deserialize<RebuildEvent>(data, options);
|
||||
|
||||
yield return deserializedData;
|
||||
|
||||
// Exit if service will go down for a clean exit
|
||||
if(deserializedData is {Type: RebuildEventType.Step, Data: "ServiceDown"})
|
||||
yield break;
|
||||
|
||||
} while (true);
|
||||
|
||||
yield return new RebuildEvent()
|
||||
|
||||
Reference in New Issue
Block a user