@@ -11,6 +11,9 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<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="Essential.LoggerProvider.Elasticsearch" Version="1.3.2" />
|
||||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.20.1" />
|
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.20.1" />
|
||||||
<PackageReference Include="NSwag.AspNetCore" Version="14.0.7" />
|
<PackageReference Include="NSwag.AspNetCore" Version="14.0.7" />
|
||||||
@@ -29,6 +32,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Managing.Bootstrap\Managing.Bootstrap.csproj" />
|
<ProjectReference Include="..\Managing.Bootstrap\Managing.Bootstrap.csproj" />
|
||||||
|
<ProjectReference Include="..\Managing.Aspire.ServiceDefaults\Managing.Aspire.ServiceDefaults.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -8,18 +8,43 @@ using Managing.Core.Middleawares;
|
|||||||
using Managing.Infrastructure.Databases.InfluxDb.Models;
|
using Managing.Infrastructure.Databases.InfluxDb.Models;
|
||||||
using Managing.Infrastructure.Databases.MongoDb.Configurations;
|
using Managing.Infrastructure.Databases.MongoDb.Configurations;
|
||||||
using Managing.Infrastructure.Evm.Models.Privy;
|
using Managing.Infrastructure.Evm.Models.Privy;
|
||||||
|
using Microsoft.Extensions.ServiceDiscovery;
|
||||||
|
using Microsoft.AspNetCore.Builder;
|
||||||
|
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
||||||
|
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.OpenApi.Models;
|
using Microsoft.OpenApi.Models;
|
||||||
using NSwag;
|
using NSwag;
|
||||||
using NSwag.Generation.Processors.Security;
|
using NSwag.Generation.Processors.Security;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using Serilog.Events;
|
using Serilog.Events;
|
||||||
using Serilog.Sinks.Elasticsearch;
|
using Serilog.Sinks.Elasticsearch;
|
||||||
|
using HealthChecks.UI.Client;
|
||||||
using OpenApiSecurityRequirement = Microsoft.OpenApi.Models.OpenApiSecurityRequirement;
|
using OpenApiSecurityRequirement = Microsoft.OpenApi.Models.OpenApiSecurityRequirement;
|
||||||
using OpenApiSecurityScheme = NSwag.OpenApiSecurityScheme;
|
using OpenApiSecurityScheme = NSwag.OpenApiSecurityScheme;
|
||||||
|
|
||||||
// Builder
|
// Builder
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
// builder.WebHost.UseUrls("http://localhost:5001");
|
|
||||||
|
// Add health checks when Aspire is enabled, in all environments
|
||||||
|
if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ASPIRE_ENABLED")))
|
||||||
|
{
|
||||||
|
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 service discovery for Aspire
|
||||||
|
builder.Services.AddServiceDiscovery();
|
||||||
|
|
||||||
|
// Configure health checks
|
||||||
|
builder.Services.AddHealthChecks()
|
||||||
|
.AddCheck("self", () => HealthCheckResult.Healthy(), ["live"])
|
||||||
|
.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.WebHost.UseUrls("http://localhost:5001");
|
||||||
builder.Configuration.SetBasePath(AppContext.BaseDirectory);
|
builder.Configuration.SetBasePath(AppContext.BaseDirectory);
|
||||||
builder.Configuration.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
builder.Configuration.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
||||||
.AddJsonFile($"appsettings.{builder.Environment.EnvironmentName}.json");
|
.AddJsonFile($"appsettings.{builder.Environment.EnvironmentName}.json");
|
||||||
@@ -152,6 +177,21 @@ app.UseEndpoints(endpoints =>
|
|||||||
{
|
{
|
||||||
endpoints.MapControllers();
|
endpoints.MapControllers();
|
||||||
endpoints.MapHub<PositionHub>("/positionhub");
|
endpoints.MapHub<PositionHub>("/positionhub");
|
||||||
|
|
||||||
|
// 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();
|
app.Run();
|
||||||
@@ -1,24 +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://localhost:9200"
|
|
||||||
},
|
|
||||||
"AllowedHosts": "*"
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
{
|
|
||||||
"ManagingDatabase": {
|
|
||||||
"ConnectionString": "mongodb://managingdb:27017",
|
|
||||||
"DatabaseName": "ManagingDb"
|
|
||||||
},
|
|
||||||
"InfluxDb": {
|
|
||||||
"Url": "http://influxdb:8086",
|
|
||||||
"Token": "OPjdwQBmKr0zQecJ10IDQ4bt32oOJzmFp687QWWzbGeyH0R-gCA6HnXI_B0oQ_InPmSUXKFje8DSAUPbY0hn-w==",
|
|
||||||
"Organization": "managing-org"
|
|
||||||
},
|
|
||||||
"Serilog": {
|
|
||||||
"MinimumLevel": {
|
|
||||||
"Default": "Information",
|
|
||||||
"Override": {
|
|
||||||
"Microsoft": "Information",
|
|
||||||
"System": "Warning"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"ElasticConfiguration": {
|
|
||||||
"Uri": "http://elasticsearch:9200"
|
|
||||||
},
|
|
||||||
"Discord": {
|
|
||||||
"ApplicationId": "966075382002516031",
|
|
||||||
"PublicKey": "63028f6bb740cd5d26ae0340b582dee2075624011b28757436255fc002ca8a7c",
|
|
||||||
"TokenId": "OTY2MDc1MzgyMDAyNTE2MDMx.Yl8dzw.xpeIAaMwGrwTNY4r9JYv0ebzb-U",
|
|
||||||
|
|
||||||
"SignalChannelId": 1134858150667898910,
|
|
||||||
"TradesChannelId": 1134858092530634864,
|
|
||||||
"TroublesChannelId": 1134858233031446671,
|
|
||||||
"CopyTradingChannelId": 1134857874896588881,
|
|
||||||
"RequestsChannelId": 1018589494968078356,
|
|
||||||
"LeaderboardChannelId": 1133169725237633095,
|
|
||||||
"NoobiesboardChannelId": 1133504653485690940,
|
|
||||||
"ButtonExpirationMinutes": 10
|
|
||||||
|
|
||||||
},
|
|
||||||
"AllowedHosts": "*"
|
|
||||||
}
|
|
||||||
31
src/Managing.Api.Workers/appsettings.Production.json
Normal file
31
src/Managing.Api.Workers/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"
|
||||||
|
},
|
||||||
|
"Serilog": {
|
||||||
|
"MinimumLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Override": {
|
||||||
|
"Microsoft": "Information",
|
||||||
|
"System": "Warning"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Web3Proxy": {
|
||||||
|
"BaseUrl": "http://srv-captain--web3-proxy:4111"
|
||||||
|
},
|
||||||
|
"ElasticConfiguration": {
|
||||||
|
"Uri": "http://elasticsearch:9200"
|
||||||
|
},
|
||||||
|
"AllowedHosts": "*"
|
||||||
|
}
|
||||||
@@ -20,6 +20,9 @@
|
|||||||
"ElasticConfiguration": {
|
"ElasticConfiguration": {
|
||||||
"Uri": "http://elasticsearch:9200"
|
"Uri": "http://elasticsearch:9200"
|
||||||
},
|
},
|
||||||
|
"Web3Proxy": {
|
||||||
|
"BaseUrl": "http://localhost:4111"
|
||||||
|
},
|
||||||
"Discord": {
|
"Discord": {
|
||||||
"BotActivity": "with jobs",
|
"BotActivity": "with jobs",
|
||||||
"HandleUserAction": true,
|
"HandleUserAction": true,
|
||||||
|
|||||||
@@ -11,6 +11,9 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<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="Essential.LoggerProvider.Elasticsearch" Version="1.3.2" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.5" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.5" />
|
||||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.20.1" />
|
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.20.1" />
|
||||||
@@ -30,6 +33,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Managing.Bootstrap\Managing.Bootstrap.csproj" />
|
<ProjectReference Include="..\Managing.Bootstrap\Managing.Bootstrap.csproj" />
|
||||||
|
<ProjectReference Include="..\Managing.Aspire.ServiceDefaults\Managing.Aspire.ServiceDefaults.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -18,11 +18,37 @@ using NSwag.Generation.Processors.Security;
|
|||||||
using Serilog;
|
using Serilog;
|
||||||
using Serilog.Events;
|
using Serilog.Events;
|
||||||
using Serilog.Sinks.Elasticsearch;
|
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 OpenApiSecurityRequirement = Microsoft.OpenApi.Models.OpenApiSecurityRequirement;
|
||||||
using OpenApiSecurityScheme = NSwag.OpenApiSecurityScheme;
|
using OpenApiSecurityScheme = NSwag.OpenApiSecurityScheme;
|
||||||
|
|
||||||
// Builder
|
// Builder
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
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.SetBasePath(AppContext.BaseDirectory);
|
||||||
builder.Configuration.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
builder.Configuration.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
||||||
.AddJsonFile($"appsettings.{builder.Environment.EnvironmentName}.json")
|
.AddJsonFile($"appsettings.{builder.Environment.EnvironmentName}.json")
|
||||||
@@ -174,6 +200,21 @@ app.UseEndpoints(endpoints =>
|
|||||||
endpoints.MapHub<BotHub>("/bothub");
|
endpoints.MapHub<BotHub>("/bothub");
|
||||||
endpoints.MapHub<BacktestHub>("/backtesthub");
|
endpoints.MapHub<BacktestHub>("/backtesthub");
|
||||||
endpoints.MapHub<CandleHub>("/candlehub");
|
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();
|
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": ""
|
"Token": ""
|
||||||
},
|
},
|
||||||
"Web3Proxy": {
|
"Web3Proxy": {
|
||||||
"BaseUrl": "http://localhost:3000"
|
"BaseUrl": "http://localhost:4111"
|
||||||
},
|
},
|
||||||
"Serilog": {
|
"Serilog": {
|
||||||
"MinimumLevel": {
|
"MinimumLevel": {
|
||||||
|
|||||||
21
src/Managing.Aspire.AppHost/Managing.Aspire.AppHost.csproj
Normal file
21
src/Managing.Aspire.AppHost/Managing.Aspire.AppHost.csproj
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<IsAspireHost>true</IsAspireHost>
|
||||||
|
<UserSecretsId>2d8fdbdd-b3e0-4716-8e00-56064804c76a</UserSecretsId>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Aspire.Hosting.AppHost" Version="8.2.2"/>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Managing.Api.Workers\Managing.Api.Workers.csproj"/>
|
||||||
|
<ProjectReference Include="..\Managing.Api\Managing.Api.csproj"/>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
13
src/Managing.Aspire.AppHost/Program.cs
Normal file
13
src/Managing.Aspire.AppHost/Program.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
var builder = DistributedApplication.CreateBuilder(args);
|
||||||
|
|
||||||
|
// Add API projects
|
||||||
|
var managingApi = builder.AddProject<Projects.Managing_Api>("managing-api");
|
||||||
|
var workersApi = builder.AddProject<Projects.Managing_Api_Workers>("worker-api");
|
||||||
|
|
||||||
|
// No need to add containers - your APIs will use their existing connection strings
|
||||||
|
// from their respective appsettings.json files
|
||||||
|
|
||||||
|
// Connect services to resources
|
||||||
|
workersApi.WithReference(managingApi);
|
||||||
|
|
||||||
|
builder.Build().Run();
|
||||||
8
src/Managing.Aspire.AppHost/appsettings.Development.json
Normal file
8
src/Managing.Aspire.AppHost/appsettings.Development.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
26
src/Managing.Aspire.AppHost/appsettings.Oda.json
Normal file
26
src/Managing.Aspire.AppHost/appsettings.Oda.json
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"ManagingDatabase": {
|
||||||
|
"ConnectionString": "mongodb://localhost:27017",
|
||||||
|
"DatabaseName": "ManagingDb"
|
||||||
|
},
|
||||||
|
"InfluxDb": {
|
||||||
|
"Url": "http://localhost:8086/",
|
||||||
|
"Organization": "managing-org",
|
||||||
|
"Token": "Fw2FPL2OwTzDHzSbR2Sd5xs0EKQYy00Q-hYKYAhr9cC1_q5YySONpxuf_Ck0PTjyUiF13xXmi__bu_pXH-H9zA=="
|
||||||
|
},
|
||||||
|
"Privy": {
|
||||||
|
"AppId": "cm6f47n1l003jx7mjwaembhup",
|
||||||
|
"AppSecret": "63Chz2z5M8TgR5qc8dznSLRAGTHTyPU4cjdQobrBF1Cx5tszZpTuFgyrRd7hZ2k6HpwDz3GEwQZzsCqHb8Z311bF"
|
||||||
|
},
|
||||||
|
"Discord": {
|
||||||
|
"ApplicationId": "",
|
||||||
|
"PublicKey": "",
|
||||||
|
"TokenId": "",
|
||||||
|
"SignalChannelId": 966080506473099314,
|
||||||
|
"TradesChannelId": 998374177763491851,
|
||||||
|
"TroublesChannelId": 1015761955321040917,
|
||||||
|
"RequestsChannelId": 1018589494968078356,
|
||||||
|
"ButtonExpirationMinutes": 2
|
||||||
|
},
|
||||||
|
"AllowedHosts": "*"
|
||||||
|
}
|
||||||
19
src/Managing.Aspire.AppHost/appsettings.ProdLocal.json
Normal file
19
src/Managing.Aspire.AppHost/appsettings.ProdLocal.json
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"ManagingDatabase": {
|
||||||
|
"ConnectionString": "mongodb://admin:r8oJiDIKbsEi@mongo-db.apps.managing.live:27017/?authMechanism=SCRAM-SHA-256",
|
||||||
|
"DatabaseName": "ManagingDb"
|
||||||
|
},
|
||||||
|
"InfluxDb": {
|
||||||
|
"Url": "https://influx-db.apps.managing.live",
|
||||||
|
"Organization": "managing-org",
|
||||||
|
"Token": "eOuXcXhH7CS13Iw4CTiDDpRjIjQtEVPOloD82pLPOejI4n0BsEj1YzUw0g3Cs1mdDG5m-RaxCavCMsVTtS5wIQ=="
|
||||||
|
},
|
||||||
|
"Privy": {
|
||||||
|
"AppId": "cm6f47n1l003jx7mjwaembhup",
|
||||||
|
"AppSecret": "63Chz2z5M8TgR5qc8dznSLRAGTHTyPU4cjdQobrBF1Cx5tszZpTuFgyrRd7hZ2k6HpwDz3GEwQZzsCqHb8Z311bF"
|
||||||
|
},
|
||||||
|
"ElasticConfiguration": {
|
||||||
|
"Uri": "http://elasticsearch:9200"
|
||||||
|
},
|
||||||
|
"AllowedHosts": "*"
|
||||||
|
}
|
||||||
9
src/Managing.Aspire.AppHost/appsettings.json
Normal file
9
src/Managing.Aspire.AppHost/appsettings.json
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning",
|
||||||
|
"Aspire.Hosting.Dcp": "Warning"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
114
src/Managing.Aspire.ServiceDefaults/Extensions.cs
Normal file
114
src/Managing.Aspire.ServiceDefaults/Extensions.cs
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
using Microsoft.AspNetCore.Builder;
|
||||||
|
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Microsoft.Extensions.ServiceDiscovery;
|
||||||
|
using OpenTelemetry;
|
||||||
|
using OpenTelemetry.Metrics;
|
||||||
|
using OpenTelemetry.Trace;
|
||||||
|
|
||||||
|
namespace Microsoft.Extensions.Hosting;
|
||||||
|
|
||||||
|
// Adds common .NET Aspire services: service discovery, resilience, health checks, and OpenTelemetry.
|
||||||
|
// This project should be referenced by each service project in your solution.
|
||||||
|
// To learn more about using this project, see https://aka.ms/dotnet/aspire/service-defaults
|
||||||
|
public static class Extensions
|
||||||
|
{
|
||||||
|
public static IHostApplicationBuilder AddServiceDefaults(this IHostApplicationBuilder builder)
|
||||||
|
{
|
||||||
|
builder.ConfigureOpenTelemetry();
|
||||||
|
|
||||||
|
builder.AddDefaultHealthChecks();
|
||||||
|
|
||||||
|
builder.Services.AddServiceDiscovery();
|
||||||
|
|
||||||
|
builder.Services.ConfigureHttpClientDefaults(http =>
|
||||||
|
{
|
||||||
|
// Turn on resilience by default
|
||||||
|
http.AddStandardResilienceHandler();
|
||||||
|
|
||||||
|
// Turn on service discovery by default
|
||||||
|
http.AddServiceDiscovery();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Uncomment the following to restrict the allowed schemes for service discovery.
|
||||||
|
// builder.Services.Configure<ServiceDiscoveryOptions>(options =>
|
||||||
|
// {
|
||||||
|
// options.AllowedSchemes = ["https"];
|
||||||
|
// });
|
||||||
|
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IHostApplicationBuilder ConfigureOpenTelemetry(this IHostApplicationBuilder builder)
|
||||||
|
{
|
||||||
|
builder.Logging.AddOpenTelemetry(logging =>
|
||||||
|
{
|
||||||
|
logging.IncludeFormattedMessage = true;
|
||||||
|
logging.IncludeScopes = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
builder.Services.AddOpenTelemetry()
|
||||||
|
.WithMetrics(metrics =>
|
||||||
|
{
|
||||||
|
metrics.AddAspNetCoreInstrumentation()
|
||||||
|
.AddHttpClientInstrumentation()
|
||||||
|
.AddRuntimeInstrumentation();
|
||||||
|
})
|
||||||
|
.WithTracing(tracing =>
|
||||||
|
{
|
||||||
|
tracing.AddAspNetCoreInstrumentation()
|
||||||
|
// Uncomment the following line to enable gRPC instrumentation (requires the OpenTelemetry.Instrumentation.GrpcNetClient package)
|
||||||
|
//.AddGrpcClientInstrumentation()
|
||||||
|
.AddHttpClientInstrumentation();
|
||||||
|
});
|
||||||
|
|
||||||
|
builder.AddOpenTelemetryExporters();
|
||||||
|
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IHostApplicationBuilder AddOpenTelemetryExporters(this IHostApplicationBuilder builder)
|
||||||
|
{
|
||||||
|
var useOtlpExporter = !string.IsNullOrWhiteSpace(builder.Configuration["OTEL_EXPORTER_OTLP_ENDPOINT"]);
|
||||||
|
|
||||||
|
if (useOtlpExporter)
|
||||||
|
{
|
||||||
|
builder.Services.AddOpenTelemetry().UseOtlpExporter();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Uncomment the following lines to enable the Azure Monitor exporter (requires the Azure.Monitor.OpenTelemetry.AspNetCore package)
|
||||||
|
//if (!string.IsNullOrEmpty(builder.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"]))
|
||||||
|
//{
|
||||||
|
// builder.Services.AddOpenTelemetry()
|
||||||
|
// .UseAzureMonitor();
|
||||||
|
//}
|
||||||
|
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IHostApplicationBuilder AddDefaultHealthChecks(this IHostApplicationBuilder builder)
|
||||||
|
{
|
||||||
|
builder.Services.AddHealthChecks()
|
||||||
|
// Add a default liveness check to ensure app is responsive
|
||||||
|
.AddCheck("self", () => HealthCheckResult.Healthy(), ["live"]);
|
||||||
|
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static WebApplication MapDefaultEndpoints(this WebApplication app)
|
||||||
|
{
|
||||||
|
// Health check endpoints are now available in all environments
|
||||||
|
// All health checks must pass for app to be considered ready to accept traffic after starting
|
||||||
|
app.MapHealthChecks("/health");
|
||||||
|
|
||||||
|
// Only health checks tagged with the "live" tag must pass for app to be considered alive
|
||||||
|
app.MapHealthChecks("/alive", new HealthCheckOptions
|
||||||
|
{
|
||||||
|
Predicate = r => r.Tags.Contains("live")
|
||||||
|
});
|
||||||
|
|
||||||
|
return app;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<IsAspireSharedProject>true</IsAspireSharedProject>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
||||||
|
<PackageReference Include="Aspire.MongoDB.Driver" Version="9.2.0" />
|
||||||
|
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="8.10.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" Version="8.2.2" />
|
||||||
|
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.9.0" />
|
||||||
|
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.9.0" />
|
||||||
|
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.9.0" />
|
||||||
|
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.9.0" />
|
||||||
|
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.9.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -64,7 +64,6 @@ public static class WorkersBootstrap
|
|||||||
services.AddSingleton<ISettingsService, SettingsService>();
|
services.AddSingleton<ISettingsService, SettingsService>();
|
||||||
services.AddSingleton<IBacktester, Backtester>();
|
services.AddSingleton<IBacktester, Backtester>();
|
||||||
services.AddSingleton<IBotService, BotService>();
|
services.AddSingleton<IBotService, BotService>();
|
||||||
|
|
||||||
services.AddTransient<ICommandHandler<OpenPositionRequest, Position>, OpenPositionCommandHandler>();
|
services.AddTransient<ICommandHandler<OpenPositionRequest, Position>, OpenPositionCommandHandler>();
|
||||||
services.AddTransient<ICommandHandler<ClosePositionCommand, Position>, ClosePositionCommandHandler>();
|
services.AddTransient<ICommandHandler<ClosePositionCommand, Position>, ClosePositionCommandHandler>();
|
||||||
|
|
||||||
@@ -119,6 +118,10 @@ public static class WorkersBootstrap
|
|||||||
services.AddSingleton<IKrakenSocketClient, KrakenSocketClient>();
|
services.AddSingleton<IKrakenSocketClient, KrakenSocketClient>();
|
||||||
services.AddSingleton<IPrivyService, PrivyService>();
|
services.AddSingleton<IPrivyService, PrivyService>();
|
||||||
|
|
||||||
|
// Web3Proxy Configuration
|
||||||
|
services.Configure<Web3ProxySettings>(configuration.GetSection("Web3Proxy"));
|
||||||
|
services.AddTransient<IWeb3ProxyService, Web3ProxyService>();
|
||||||
|
|
||||||
// Messengers
|
// Messengers
|
||||||
services.AddSingleton<IMessengerService, MessengerService>();
|
services.AddSingleton<IMessengerService, MessengerService>();
|
||||||
services.AddSingleton<IDiscordService, DiscordService>();
|
services.AddSingleton<IDiscordService, DiscordService>();
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ const plugin: FastifyPluginAsyncTypebox = async (fastify) => {
|
|||||||
return { message: 'Welcome to the official Web3 Proxy API!' }
|
return { message: 'Welcome to the official Web3 Proxy API!' }
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
// Add health check endpoint
|
||||||
|
fastify.get('/health', async function () {
|
||||||
|
return { status: 'ok' }
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export default plugin
|
export default plugin
|
||||||
|
|||||||
@@ -66,6 +66,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Managing.ABI.GmxV2", "Managing.ABI.GmxV2\Managing.ABI.GmxV2.csproj", "{4521E1A9-AF81-4CA8-8B4D-30C261ECE977}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Managing.ABI.GmxV2", "Managing.ABI.GmxV2\Managing.ABI.GmxV2.csproj", "{4521E1A9-AF81-4CA8-8B4D-30C261ECE977}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Managing.Aspire.AppHost", "Managing.Aspire.AppHost\Managing.Aspire.AppHost.csproj", "{2A7AC5A7-B4D6-4DF2-976B-6EE771BB4C31}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Managing.Aspire.ServiceDefaults", "Managing.Aspire.ServiceDefaults\Managing.Aspire.ServiceDefaults.csproj", "{F58949B8-4173-4F9E-83FF-B88FA2C5C849}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -226,6 +230,22 @@ Global
|
|||||||
{4521E1A9-AF81-4CA8-8B4D-30C261ECE977}.Release|Any CPU.Build.0 = Release|Any CPU
|
{4521E1A9-AF81-4CA8-8B4D-30C261ECE977}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{4521E1A9-AF81-4CA8-8B4D-30C261ECE977}.Release|x64.ActiveCfg = Release|Any CPU
|
{4521E1A9-AF81-4CA8-8B4D-30C261ECE977}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
{4521E1A9-AF81-4CA8-8B4D-30C261ECE977}.Release|x64.Build.0 = Release|Any CPU
|
{4521E1A9-AF81-4CA8-8B4D-30C261ECE977}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{2A7AC5A7-B4D6-4DF2-976B-6EE771BB4C31}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{2A7AC5A7-B4D6-4DF2-976B-6EE771BB4C31}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{2A7AC5A7-B4D6-4DF2-976B-6EE771BB4C31}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{2A7AC5A7-B4D6-4DF2-976B-6EE771BB4C31}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{2A7AC5A7-B4D6-4DF2-976B-6EE771BB4C31}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{2A7AC5A7-B4D6-4DF2-976B-6EE771BB4C31}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{2A7AC5A7-B4D6-4DF2-976B-6EE771BB4C31}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{2A7AC5A7-B4D6-4DF2-976B-6EE771BB4C31}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{F58949B8-4173-4F9E-83FF-B88FA2C5C849}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{F58949B8-4173-4F9E-83FF-B88FA2C5C849}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{F58949B8-4173-4F9E-83FF-B88FA2C5C849}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{F58949B8-4173-4F9E-83FF-B88FA2C5C849}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{F58949B8-4173-4F9E-83FF-B88FA2C5C849}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{F58949B8-4173-4F9E-83FF-B88FA2C5C849}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{F58949B8-4173-4F9E-83FF-B88FA2C5C849}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{F58949B8-4173-4F9E-83FF-B88FA2C5C849}.Release|x64.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
1
src/dotnet9-sdk-installer.pkg
Normal file
1
src/dotnet9-sdk-installer.pkg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
GatewayExceptionResponse
|
||||||
9
src/run-aspire.sh
Executable file
9
src/run-aspire.sh
Executable file
@@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Set environment variables
|
||||||
|
export ASPIRE_ENABLED=true
|
||||||
|
export ASPNETCORE_ENVIRONMENT=Oda
|
||||||
|
|
||||||
|
echo "Starting Aspire dashboard using existing MongoDB and InfluxDB..."
|
||||||
|
echo "Environment: $ASPNETCORE_ENVIRONMENT"
|
||||||
|
echo "Health endpoints will be available at /health and /alive on both APIs"
|
||||||
|
echo "Dashboard will be available at http://localhost:15888"
|
||||||
Reference in New Issue
Block a user