Redis Issue - may be fixed.
This commit is contained in:
+8
-10
@@ -37,7 +37,7 @@ builder.Services.AddSession(options =>
|
|||||||
options.IdleTimeout = TimeSpan.FromHours(8);
|
options.IdleTimeout = TimeSpan.FromHours(8);
|
||||||
options.Cookie.HttpOnly = true;
|
options.Cookie.HttpOnly = true;
|
||||||
options.Cookie.IsEssential = true;
|
options.Cookie.IsEssential = true;
|
||||||
options.Cookie.Name = ".VoidScavengers.Admin.2";
|
options.Cookie.Name = ".Divers.Admin";
|
||||||
});
|
});
|
||||||
|
|
||||||
// ---- MySQL conn string from env ----
|
// ---- MySQL conn string from env ----
|
||||||
@@ -61,6 +61,13 @@ builder.Services.AddOptions<DatabaseOptions>()
|
|||||||
.ValidateOnStart();
|
.ValidateOnStart();
|
||||||
|
|
||||||
// Redis + zone leases + WAL
|
// Redis + zone leases + WAL
|
||||||
|
//builder.Services.AddSingleton<IRedisManager, RedisManager>();
|
||||||
|
var redisCs = RedisManager.BuildRedisConnectionStringFromEnv()
|
||||||
|
?? throw new Exception("REDIS_CONNECTION_STRING required");
|
||||||
|
|
||||||
|
var redisMux = ConnectionMultiplexer.Connect(redisCs);
|
||||||
|
|
||||||
|
builder.Services.AddSingleton<IConnectionMultiplexer>(redisMux);
|
||||||
builder.Services.AddSingleton<IRedisManager, RedisManager>();
|
builder.Services.AddSingleton<IRedisManager, RedisManager>();
|
||||||
|
|
||||||
builder.Services.AddScoped<IAccountsRepository, AccountsRepository>();
|
builder.Services.AddScoped<IAccountsRepository, AccountsRepository>();
|
||||||
@@ -82,20 +89,11 @@ builder.Services.AddSingleton<IAdminAuthService, AdminAuthService>();
|
|||||||
builder.Services.AddSingleton<ICdnBrowserService, MinioCdnBrowserService>();
|
builder.Services.AddSingleton<ICdnBrowserService, MinioCdnBrowserService>();
|
||||||
builder.Services.AddSingleton<IServerBroadcastService, ServerBroadcastService>();
|
builder.Services.AddSingleton<IServerBroadcastService, ServerBroadcastService>();
|
||||||
builder.Services.AddHttpClient(); // For CDN file hash computation
|
builder.Services.AddHttpClient(); // For CDN file hash computation
|
||||||
Console.WriteLine("Burning it down");
|
|
||||||
|
|
||||||
// Health checks
|
// Health checks
|
||||||
builder.Services.AddHealthChecks()
|
builder.Services.AddHealthChecks()
|
||||||
.AddCheck<DatabaseHealthCheck>("mysql", tags: new[] { "ready" });
|
.AddCheck<DatabaseHealthCheck>("mysql", tags: new[] { "ready" });
|
||||||
|
|
||||||
var redisCs = RedisManager.BuildRedisConnectionStringFromEnv()
|
|
||||||
?? throw new Exception("REDIS_CONNECTION_STRING required");
|
|
||||||
|
|
||||||
var redisMux = ConnectionMultiplexer.Connect(redisCs);
|
|
||||||
builder.Services.AddSingleton<IConnectionMultiplexer>(redisMux);
|
|
||||||
|
|
||||||
builder.Services.AddSingleton<IRedisManager, RedisManager>();
|
|
||||||
|
|
||||||
builder.Services.AddDataProtection()
|
builder.Services.AddDataProtection()
|
||||||
.SetApplicationName("Void")
|
.SetApplicationName("Void")
|
||||||
.PersistKeysToStackExchangeRedis(() => redisMux.GetDatabase(), "Void:DataProtectionKeys");
|
.PersistKeysToStackExchangeRedis(() => redisMux.GetDatabase(), "Void:DataProtectionKeys");
|
||||||
|
|||||||
@@ -30,7 +30,8 @@ public interface IRedisManager : IAsyncDisposable
|
|||||||
public sealed class RedisManager : IRedisManager
|
public sealed class RedisManager : IRedisManager
|
||||||
{
|
{
|
||||||
private readonly ILogger<RedisManager> _logger;
|
private readonly ILogger<RedisManager> _logger;
|
||||||
private readonly ConnectionMultiplexer _mux;
|
//private readonly ConnectionMultiplexer _mux;
|
||||||
|
private readonly IConnectionMultiplexer _mux;
|
||||||
|
|
||||||
public IDatabase Db => _mux.GetDatabase();
|
public IDatabase Db => _mux.GetDatabase();
|
||||||
public ISubscriber Bus => _mux.GetSubscriber();
|
public ISubscriber Bus => _mux.GetSubscriber();
|
||||||
@@ -41,20 +42,16 @@ public sealed class RedisManager : IRedisManager
|
|||||||
WriteIndented = false
|
WriteIndented = false
|
||||||
};
|
};
|
||||||
|
|
||||||
public RedisManager(ILogger<RedisManager> logger)
|
public RedisManager(ILogger<RedisManager> logger, IConnectionMultiplexer mux)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
|
|
||||||
var connString = BuildRedisConnectionStringFromEnv();
|
var connString = BuildRedisConnectionStringFromEnv();
|
||||||
_mux = ConnectionMultiplexer.Connect(connString);
|
_mux = mux;//ConnectionMultiplexer.Connect(connString);
|
||||||
_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()
|
||||||
|
|||||||
Reference in New Issue
Block a user