@@ -11,6 +11,9 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AspNetCore.HealthChecks.MongoDb" Version="8.1.0" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="9.0.0" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.Uris" Version="9.0.0" />
|
||||
<PackageReference Include="Essential.LoggerProvider.Elasticsearch" Version="1.3.2" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.5" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.20.1" />
|
||||
@@ -30,6 +33,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Managing.Bootstrap\Managing.Bootstrap.csproj" />
|
||||
<ProjectReference Include="..\Managing.Aspire.ServiceDefaults\Managing.Aspire.ServiceDefaults.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -18,11 +18,37 @@ 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;
|
||||
|
||||
// Builder
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Set up Aspire telemetry and health checks when enabled, in all environments
|
||||
if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ASPIRE_ENABLED")))
|
||||
{
|
||||
// Add Service Defaults - using extension methods directly
|
||||
builder.Services.AddServiceDiscovery();
|
||||
builder.Services.AddHealthChecks()
|
||||
.AddCheck("self", () => HealthCheckResult.Healthy(), ["live"]);
|
||||
|
||||
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 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"]);
|
||||
}
|
||||
|
||||
builder.Configuration.SetBasePath(AppContext.BaseDirectory);
|
||||
builder.Configuration.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
||||
.AddJsonFile($"appsettings.{builder.Environment.EnvironmentName}.json")
|
||||
@@ -174,6 +200,21 @@ app.UseEndpoints(endpoints =>
|
||||
endpoints.MapHub<BotHub>("/bothub");
|
||||
endpoints.MapHub<BacktestHub>("/backtesthub");
|
||||
endpoints.MapHub<CandleHub>("/candlehub");
|
||||
|
||||
// Always add health check endpoints when Aspire is enabled, regardless of environment
|
||||
if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ASPIRE_ENABLED")))
|
||||
{
|
||||
endpoints.MapHealthChecks("/health", new HealthCheckOptions
|
||||
{
|
||||
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
|
||||
});
|
||||
|
||||
endpoints.MapHealthChecks("/alive", new HealthCheckOptions
|
||||
{
|
||||
Predicate = r => r.Tags.Contains("live"),
|
||||
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
app.Run();
|
||||
@@ -1,34 +0,0 @@
|
||||
{
|
||||
"ManagingDatabase": {
|
||||
"ConnectionString": "mongodb://localhost:27017",
|
||||
"DatabaseName": "ManagingDb"
|
||||
},
|
||||
"InfluxDb": {
|
||||
"Url": "http://localhost:8086/",
|
||||
"Organization": "",
|
||||
"Token": ""
|
||||
},
|
||||
"Serilog": {
|
||||
"MinimumLevel": {
|
||||
"Default": "Information",
|
||||
"Override": {
|
||||
"Microsoft": "Information",
|
||||
"System": "Warning"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ElasticConfiguration": {
|
||||
"Uri": "http://elasticsearch:9200"
|
||||
},
|
||||
"Discord": {
|
||||
"ApplicationId": "",
|
||||
"PublicKey": "",
|
||||
"SignalChannelId": 1018897743118340180,
|
||||
"TroublesChannelId": 1018897743118340180,
|
||||
"TradesChannelId": 1020457417877753886,
|
||||
"RequestChannelId": 1020463151034138694,
|
||||
"RequestsChannelId": 1020463151034138694,
|
||||
"ButtonExpirationMinutes": 2
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
31
src/Managing.Api/appsettings.Production.json
Normal file
31
src/Managing.Api/appsettings.Production.json
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"ManagingDatabase": {
|
||||
"ConnectionString": "mongodb://admin:r8oJiDIKbsEi@srv-captain--mongo-db:27017/?authMechanism=SCRAM-SHA-256",
|
||||
"DatabaseName": "ManagingDb"
|
||||
},
|
||||
"InfluxDb": {
|
||||
"Url": "http://srv-captain--influx-db:8086/",
|
||||
"Organization": "managing-org",
|
||||
"Token": "eOuXcXhH7CS13Iw4CTiDDpRjIjQtEVPOloD82pLPOejI4n0BsEj1YzUw0g3Cs1mdDG5m-RaxCavCMsVTtS5wIQ=="
|
||||
},
|
||||
"Privy": {
|
||||
"AppId": "cm6f47n1l003jx7mjwaembhup",
|
||||
"AppSecret": "63Chz2z5M8TgR5qc8dznSLRAGTHTyPU4cjdQobrBF1Cx5tszZpTuFgyrRd7hZ2k6HpwDz3GEwQZzsCqHb8Z311bF"
|
||||
},
|
||||
"Web3Proxy": {
|
||||
"BaseUrl": "http://srv-captain--web3-proxy:4111"
|
||||
},
|
||||
"Serilog": {
|
||||
"MinimumLevel": {
|
||||
"Default": "Information",
|
||||
"Override": {
|
||||
"Microsoft": "Information",
|
||||
"System": "Warning"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ElasticConfiguration": {
|
||||
"Uri": "http://elasticsearch:9200"
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
@@ -22,7 +22,7 @@
|
||||
"Token": ""
|
||||
},
|
||||
"Web3Proxy": {
|
||||
"BaseUrl": "http://localhost:3000"
|
||||
"BaseUrl": "http://localhost:4111"
|
||||
},
|
||||
"Serilog": {
|
||||
"MinimumLevel": {
|
||||
|
||||
Reference in New Issue
Block a user