[backend/configuration] Allow connecting to redis unix sockets, document connecting to postgres unix sockets (ISH-76)
This commit is contained in:
parent
7c8dde9deb
commit
70657e1650
3 changed files with 14 additions and 4 deletions
|
@ -33,7 +33,7 @@ public sealed class Config {
|
|||
|
||||
public int ListenPort { get; init; } = 3000;
|
||||
public string ListenHost { get; init; } = "localhost";
|
||||
public string? ListenSocket { get; init; } = null;
|
||||
public string? ListenSocket { get; init; }
|
||||
public string WebDomain { get; init; } = null!;
|
||||
public string AccountDomain { get; init; } = null!;
|
||||
public int CharacterLimit { get; init; } = 8192;
|
||||
|
@ -59,6 +59,7 @@ public sealed class Config {
|
|||
public sealed class RedisSection {
|
||||
public string Host { get; init; } = "localhost";
|
||||
public int Port { get; init; } = 6379;
|
||||
public string? UnixDomainSocket { get; init; }
|
||||
public string? Prefix { get; init; }
|
||||
public string? Username { get; init; }
|
||||
public string? Password { get; init; }
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using System.Net.Sockets;
|
||||
using System.Threading.RateLimiting;
|
||||
using Iceshrimp.Backend.Controllers.Mastodon.Renderers;
|
||||
using Iceshrimp.Backend.Controllers.Schemas;
|
||||
|
@ -97,15 +98,19 @@ public static class ServiceExtensions {
|
|||
if (redis == null || instance == null)
|
||||
throw new Exception("Failed to initialize redis: Failed to load configuration");
|
||||
|
||||
|
||||
var redisOptions = new ConfigurationOptions {
|
||||
User = redis.Username,
|
||||
Password = redis.Password,
|
||||
DefaultDatabase = redis.Database,
|
||||
EndPoints = new EndPointCollection {
|
||||
{ redis.Host, redis.Port }
|
||||
}
|
||||
EndPoints = new EndPointCollection()
|
||||
};
|
||||
|
||||
if (redis.UnixDomainSocket != null)
|
||||
redisOptions.EndPoints.Add(new UnixDomainSocketEndPoint(redis.UnixDomainSocket));
|
||||
else
|
||||
redisOptions.EndPoints.Add(redis.Host, redis.Port);
|
||||
|
||||
services.AddSingleton<IConnectionMultiplexer>(_ => ConnectionMultiplexer.Connect(redisOptions));
|
||||
|
||||
services.AddStackExchangeRedisCache(options => {
|
||||
|
|
|
@ -39,6 +39,7 @@ ExposeFederationList = Registered
|
|||
ExposeBlockReasons = Registered
|
||||
|
||||
[Database]
|
||||
;; Hostname, IP address or path to unix socket directory (specifying port is required even for unix sockets)
|
||||
Host = localhost
|
||||
Port = 5432
|
||||
Database = iceshrimp
|
||||
|
@ -53,6 +54,9 @@ Port = 6379
|
|||
;;Password =
|
||||
;;Database = 0
|
||||
|
||||
;; If you prefer connecting to your redis instance via a unix socket, uncomment the line below & specify the socket path
|
||||
;;UnixDomainSocket =
|
||||
|
||||
[Storage]
|
||||
;; Where to store media attachments
|
||||
;; Options: [Local, ObjectStorage]
|
||||
|
|
Loading…
Add table
Reference in a new issue