fix(server): fixes status path returns database path and error message to clients
This commit is contained in:
@@ -198,15 +198,11 @@ app.MapGet(settings.StatusPath, (HttpContext context, TunnelHub hub, ServerSetti
|
|||||||
embeddingCache = new
|
embeddingCache = new
|
||||||
{
|
{
|
||||||
available = embeddingCache.IsAvailable,
|
available = embeddingCache.IsAvailable,
|
||||||
count = embeddingCache.Count,
|
count = embeddingCache.Count
|
||||||
databasePath = embeddingCache.DatabasePath,
|
|
||||||
lastError = embeddingCache.LastError
|
|
||||||
},
|
},
|
||||||
management = new
|
management = new
|
||||||
{
|
{
|
||||||
available = managementStore.IsAvailable,
|
available = managementStore.IsAvailable
|
||||||
databasePath = managementStore.DatabasePath,
|
|
||||||
lastError = managementStore.LastError
|
|
||||||
},
|
},
|
||||||
clients = hub.ClientsSnapshot
|
clients = hub.ClientsSnapshot
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
using ElmahCore;
|
||||||
using Microsoft.AspNetCore.Http.Features;
|
using Microsoft.AspNetCore.Http.Features;
|
||||||
using Microsoft.Extensions.Primitives;
|
using Microsoft.Extensions.Primitives;
|
||||||
using ReverseLlama.Protocol;
|
using ReverseLlama.Protocol;
|
||||||
@@ -569,10 +570,16 @@ internal static class ReverseProxyEndpoint
|
|||||||
{
|
{
|
||||||
logger.LogWarning(exception, "Proxy request {RequestId} failed.", requestId);
|
logger.LogWarning(exception, "Proxy request {RequestId} failed.", requestId);
|
||||||
|
|
||||||
|
var errorLog = context.RequestServices.GetService<ErrorLog>();
|
||||||
|
if (errorLog is not null)
|
||||||
|
{
|
||||||
|
await errorLog.LogAsync(new Error(exception, context));
|
||||||
|
}
|
||||||
|
|
||||||
if (!context.Response.HasStarted)
|
if (!context.Response.HasStarted)
|
||||||
{
|
{
|
||||||
context.Response.StatusCode = StatusCodes.Status502BadGateway;
|
context.Response.StatusCode = StatusCodes.Status502BadGateway;
|
||||||
await context.Response.WriteAsync(exception.Message, CancellationToken.None);
|
await context.Response.WriteAsync("Bad gateway", CancellationToken.None);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user