Fix bot + disable position fetcher
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
using System.Text;
|
||||
using System.Text.Json.Serialization;
|
||||
using HealthChecks.UI.Client;
|
||||
using Managing.Api.Authorization;
|
||||
using Managing.Api.Filters;
|
||||
using Managing.Api.HealthChecks;
|
||||
using Managing.Api.Workers;
|
||||
using Managing.Application.Hubs;
|
||||
using Managing.Bootstrap;
|
||||
@@ -11,6 +13,8 @@ using Managing.Infrastructure.Databases.InfluxDb.Models;
|
||||
using Managing.Infrastructure.Databases.MongoDb.Configurations;
|
||||
using Managing.Infrastructure.Evm.Models.Privy;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
||||
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using NSwag;
|
||||
@@ -18,15 +22,8 @@ using NSwag.Generation.Processors.Security;
|
||||
using Serilog;
|
||||
using Serilog.Events;
|
||||
using Serilog.Sinks.Elasticsearch;
|
||||
using Microsoft.Extensions.ServiceDiscovery;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
||||
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using HealthChecks.UI.Client;
|
||||
using OpenApiSecurityRequirement = Microsoft.OpenApi.Models.OpenApiSecurityRequirement;
|
||||
using OpenApiSecurityScheme = NSwag.OpenApiSecurityScheme;
|
||||
using Sentry;
|
||||
|
||||
// Builder
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
@@ -69,17 +66,35 @@ SentrySdk.Init(options =>
|
||||
// Add Service Defaults - using extension methods directly
|
||||
builder.Services.AddServiceDiscovery();
|
||||
builder.Services.AddHealthChecks()
|
||||
.AddCheck("self", () => HealthCheckResult.Healthy(), ["live"]);
|
||||
.AddCheck("self", () => HealthCheckResult.Healthy(), ["api"]);
|
||||
|
||||
var mongoConnectionString = builder.Configuration.GetSection(Constants.Databases.MongoDb)["ConnectionString"];
|
||||
var influxUrl = builder.Configuration.GetSection(Constants.Databases.InfluxDb)["Url"];
|
||||
var web3ProxyUrl = builder.Configuration.GetSection("Web3Proxy")["BaseUrl"];
|
||||
|
||||
// Add HTTP client for Web3Proxy health check with detailed response
|
||||
builder.Services.AddHttpClient("Web3ProxyHealthCheck")
|
||||
.ConfigureHttpClient(client => {
|
||||
client.Timeout = TimeSpan.FromSeconds(15);
|
||||
});
|
||||
|
||||
// Add HTTP client for GMX API health check
|
||||
builder.Services.AddHttpClient("GmxHealthCheck")
|
||||
.ConfigureHttpClient(client => {
|
||||
client.Timeout = TimeSpan.FromSeconds(10);
|
||||
});
|
||||
|
||||
// Register Web3ProxyHealthCheck with the web3ProxyUrl
|
||||
builder.Services.AddSingleton<Web3ProxyHealthCheck>(sp =>
|
||||
new Web3ProxyHealthCheck(sp.GetRequiredService<IHttpClientFactory>(), web3ProxyUrl));
|
||||
|
||||
// Add specific health checks for databases and other services
|
||||
builder.Services.AddHealthChecks()
|
||||
.AddMongoDb(mongoConnectionString, name: "mongodb", tags: ["database"])
|
||||
.AddUrlGroup(new Uri($"{influxUrl}/health"), name: "influxdb", tags: ["database"])
|
||||
.AddUrlGroup(new Uri($"{web3ProxyUrl}/health"), name: "web3proxy", tags: ["api"]);
|
||||
.AddCheck<Web3ProxyHealthCheck>("web3proxy", tags: ["api", "external"])
|
||||
.AddCheck<CandleDataHealthCheck>("candle-data", tags: ["database", "candles"])
|
||||
.AddCheck<GmxConnectivityHealthCheck>("gmx-connectivity", tags: ["api", "external"]);
|
||||
|
||||
builder.Host.UseSerilog((hostBuilder, loggerConfiguration) =>
|
||||
{
|
||||
@@ -185,7 +200,7 @@ builder.Services.AddSwaggerGen(options =>
|
||||
});
|
||||
|
||||
builder.WebHost.SetupDiscordBot();
|
||||
// builder.Services.AddHostedService<BotManagerWorker>();
|
||||
builder.Services.AddHostedService<BotManagerWorker>();
|
||||
|
||||
// App
|
||||
var app = builder.Build();
|
||||
@@ -238,6 +253,24 @@ app.UseEndpoints(endpoints =>
|
||||
Predicate = r => r.Tags.Contains("live"),
|
||||
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
|
||||
});
|
||||
|
||||
endpoints.MapHealthChecks("/health/candles", new HealthCheckOptions
|
||||
{
|
||||
Predicate = r => r.Tags.Contains("candles"),
|
||||
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
|
||||
});
|
||||
|
||||
endpoints.MapHealthChecks("/health/gmx", new HealthCheckOptions
|
||||
{
|
||||
Predicate = r => r.Name == "gmx-connectivity",
|
||||
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
|
||||
});
|
||||
|
||||
endpoints.MapHealthChecks("/health/web3proxy", new HealthCheckOptions
|
||||
{
|
||||
Predicate = r => r.Name == "web3proxy",
|
||||
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
|
||||
});
|
||||
});
|
||||
|
||||
app.Run();
|
||||
Reference in New Issue
Block a user