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