From 46c6973ae8fd25d6a64b817591819529724ebb7a Mon Sep 17 00:00:00 2001 From: dingo Date: Fri, 30 Jan 2026 11:08:47 -0500 Subject: [PATCH] DPM --- Program.cs | 24 ++++++++++++++++++++---- Redis/IRedisManager.cs | 6 ++++++ SystemRevivalServer.csproj | 1 + 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/Program.cs b/Program.cs index 699bc46..63133ce 100644 --- a/Program.cs +++ b/Program.cs @@ -1,20 +1,22 @@ using System.Net; using System.Net.Sockets; +using DataServer.Data; +using GameServer; using GameServer.Dungeon; +using GameServices; +using GameServices.Auth; using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Http; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Diagnostics.HealthChecks; using Microsoft.Extensions.Hosting; -using DataServer.Data; using Server.Networking; using Server.Networking.Handling; using Server.Networking.Messages; using Server.Redis; -using GameServices; -using GameServices.Auth; -using GameServer; +using StackExchange.Redis; var builder = WebApplication.CreateBuilder(args); @@ -83,6 +85,20 @@ builder.Services.AddHttpClient(); // For CDN file hash computation builder.Services.AddHealthChecks() .AddCheck("mysql", tags: new[] { "ready" }); +builder.Services.AddSingleton(_ => +{ + var cs = Environment.GetEnvironmentVariable("REDIS_CONNECTION_STRING") + ?? throw new Exception("REDIS_CONNECTION_STRING required"); + return ConnectionMultiplexer.Connect(cs); +}); +builder.Services.AddSingleton(sp => + sp.GetRequiredService().GetDatabase()); + +builder.Services.AddDataProtection() + .SetApplicationName("Void") + .PersistKeysToStackExchangeRedis( + () => builder.Services.BuildServiceProvider().GetRequiredService(), + "Void:DataProtectionKeys"); //var app = builder.Build(); //// DEBUG: Log registered handlers diff --git a/Redis/IRedisManager.cs b/Redis/IRedisManager.cs index 828539a..02b1602 100644 --- a/Redis/IRedisManager.cs +++ b/Redis/IRedisManager.cs @@ -50,6 +50,12 @@ public sealed class RedisManager : IRedisManager _logger.LogInformation("Connected to Redis: {Endpoints}", string.Join(",", _mux.GetEndPoints().Select(ep => ep.ToString()))); } + public RedisManager(ILogger logger, IConnectionMultiplexer mux) + { + _logger = logger; + _mux = (ConnectionMultiplexer)mux; + } + public async ValueTask DisposeAsync() { diff --git a/SystemRevivalServer.csproj b/SystemRevivalServer.csproj index 947470d..f7547c0 100644 --- a/SystemRevivalServer.csproj +++ b/SystemRevivalServer.csproj @@ -10,6 +10,7 @@ + runtime; build; native; contentfiles; analyzers; buildtransitive