DPM
This commit is contained in:
+20
-4
@@ -1,20 +1,22 @@
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
|
using DataServer.Data;
|
||||||
|
using GameServer;
|
||||||
using GameServer.Dungeon;
|
using GameServer.Dungeon;
|
||||||
|
using GameServices;
|
||||||
|
using GameServices.Auth;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
|
using Microsoft.AspNetCore.DataProtection;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using DataServer.Data;
|
|
||||||
using Server.Networking;
|
using Server.Networking;
|
||||||
using Server.Networking.Handling;
|
using Server.Networking.Handling;
|
||||||
using Server.Networking.Messages;
|
using Server.Networking.Messages;
|
||||||
using Server.Redis;
|
using Server.Redis;
|
||||||
using GameServices;
|
using StackExchange.Redis;
|
||||||
using GameServices.Auth;
|
|
||||||
using GameServer;
|
|
||||||
|
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
@@ -83,6 +85,20 @@ builder.Services.AddHttpClient(); // For CDN file hash computation
|
|||||||
builder.Services.AddHealthChecks()
|
builder.Services.AddHealthChecks()
|
||||||
.AddCheck<DatabaseHealthCheck>("mysql", tags: new[] { "ready" });
|
.AddCheck<DatabaseHealthCheck>("mysql", tags: new[] { "ready" });
|
||||||
|
|
||||||
|
builder.Services.AddSingleton<IConnectionMultiplexer>(_ =>
|
||||||
|
{
|
||||||
|
var cs = Environment.GetEnvironmentVariable("REDIS_CONNECTION_STRING")
|
||||||
|
?? throw new Exception("REDIS_CONNECTION_STRING required");
|
||||||
|
return ConnectionMultiplexer.Connect(cs);
|
||||||
|
});
|
||||||
|
builder.Services.AddSingleton(sp =>
|
||||||
|
sp.GetRequiredService<IConnectionMultiplexer>().GetDatabase());
|
||||||
|
|
||||||
|
builder.Services.AddDataProtection()
|
||||||
|
.SetApplicationName("Void")
|
||||||
|
.PersistKeysToStackExchangeRedis(
|
||||||
|
() => builder.Services.BuildServiceProvider().GetRequiredService<IDatabase>(),
|
||||||
|
"Void:DataProtectionKeys");
|
||||||
//var app = builder.Build();
|
//var app = builder.Build();
|
||||||
|
|
||||||
//// DEBUG: Log registered handlers
|
//// DEBUG: Log registered handlers
|
||||||
|
|||||||
@@ -50,6 +50,12 @@ public sealed class RedisManager : IRedisManager
|
|||||||
_logger.LogInformation("Connected to Redis: {Endpoints}",
|
_logger.LogInformation("Connected to Redis: {Endpoints}",
|
||||||
string.Join(",", _mux.GetEndPoints().Select(ep => ep.ToString())));
|
string.Join(",", _mux.GetEndPoints().Select(ep => ep.ToString())));
|
||||||
}
|
}
|
||||||
|
public RedisManager(ILogger<RedisManager> logger, IConnectionMultiplexer mux)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_mux = (ConnectionMultiplexer)mux;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public async ValueTask DisposeAsync()
|
public async ValueTask DisposeAsync()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="10.0.2" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.10" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.10" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.10">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.10">
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
|||||||
Reference in New Issue
Block a user