summary refs log tree commit diff
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2026-03-19 08:38:20 +0100
committerRory& <root@rory.gay>2026-03-19 08:38:20 +0100
commitd0eac0b8e7738c645707b52e386ca1e2079b8da8 (patch)
treec8fc5b135ec94f6351e025ff7df472f83db4c6c5
parentCDN: use file contents for hashes, the fuck (diff)
downloadserver-ts-d0eac0b8e7738c645707b52e386ca1e2079b8da8.tar.xz
GatewayOffload: rename to Offload
-rw-r--r--extra/admin-api/Spacebar.Offload/Controllers/ChannelStatusController.cs (renamed from extra/admin-api/Spacebar.GatewayOffload/Controllers/ChannelStatusController.cs)0
-rw-r--r--extra/admin-api/Spacebar.Offload/Controllers/IdentifyController.cs (renamed from extra/admin-api/Spacebar.GatewayOffload/Controllers/IdentifyController.cs)0
-rw-r--r--extra/admin-api/Spacebar.Offload/Controllers/Op12Controller.cs (renamed from extra/admin-api/Spacebar.GatewayOffload/Controllers/Op12Controller.cs)0
-rw-r--r--extra/admin-api/Spacebar.Offload/Controllers/Op14Controller.cs (renamed from extra/admin-api/Spacebar.GatewayOffload/Controllers/Op14Controller.cs)0
-rw-r--r--extra/admin-api/Spacebar.Offload/Controllers/Op8Controller.cs (renamed from extra/admin-api/Spacebar.GatewayOffload/Controllers/Op8Controller.cs)0
-rw-r--r--extra/admin-api/Spacebar.Offload/Extensions/Db/UserExtensions.cs (renamed from extra/admin-api/Spacebar.GatewayOffload/Extensions/Db/UserExtensions.cs)0
-rw-r--r--extra/admin-api/Spacebar.Offload/Program.cs (renamed from extra/admin-api/Spacebar.GatewayOffload/Program.cs)0
-rw-r--r--extra/admin-api/Spacebar.Offload/Properties/launchSettings.json (renamed from extra/admin-api/Spacebar.GatewayOffload/Properties/launchSettings.json)0
-rw-r--r--extra/admin-api/Spacebar.Offload/Spacebar.Offload.csproj (renamed from extra/admin-api/Spacebar.GatewayOffload/Spacebar.GatewayOffload.csproj)0
-rw-r--r--extra/admin-api/Spacebar.Offload/Spacebar.Offload.http (renamed from extra/admin-api/Spacebar.GatewayOffload/Spacebar.GatewayOffload.http)0
-rw-r--r--extra/admin-api/Spacebar.Offload/appsettings.Development.json (renamed from extra/admin-api/Spacebar.GatewayOffload/appsettings.Development.json)0
-rw-r--r--extra/admin-api/Spacebar.Offload/appsettings.json (renamed from extra/admin-api/Spacebar.GatewayOffload/appsettings.json)0
-rw-r--r--extra/admin-api/Spacebar.Offload/deps.json (renamed from extra/admin-api/Spacebar.GatewayOffload/deps.json)0
-rw-r--r--extra/admin-api/Spacebar.Offload/http-client.private.env.json5
-rw-r--r--extra/admin-api/Spacebar.UApi/Program.cs2
-rw-r--r--extra/admin-api/SpacebarAdminAPI.slnx2
-rw-r--r--extra/admin-api/outputs.nix28
-rw-r--r--nix/modules/default/cs/gateway-offload-cs.nix89
-rw-r--r--nix/modules/default/cs/offload-cs.nix97
-rw-r--r--nix/modules/default/default.nix2
-rw-r--r--nix/testVm/configuration.nix35
-rw-r--r--nix/tests/test-bundle-starts.nix6
22 files changed, 147 insertions, 119 deletions
diff --git a/extra/admin-api/Spacebar.GatewayOffload/Controllers/ChannelStatusController.cs b/extra/admin-api/Spacebar.Offload/Controllers/ChannelStatusController.cs

index 0843218e..0843218e 100644 --- a/extra/admin-api/Spacebar.GatewayOffload/Controllers/ChannelStatusController.cs +++ b/extra/admin-api/Spacebar.Offload/Controllers/ChannelStatusController.cs
diff --git a/extra/admin-api/Spacebar.GatewayOffload/Controllers/IdentifyController.cs b/extra/admin-api/Spacebar.Offload/Controllers/IdentifyController.cs
index 02bad394..02bad394 100644 --- a/extra/admin-api/Spacebar.GatewayOffload/Controllers/IdentifyController.cs +++ b/extra/admin-api/Spacebar.Offload/Controllers/IdentifyController.cs
diff --git a/extra/admin-api/Spacebar.GatewayOffload/Controllers/Op12Controller.cs b/extra/admin-api/Spacebar.Offload/Controllers/Op12Controller.cs
index 884a9de8..884a9de8 100644 --- a/extra/admin-api/Spacebar.GatewayOffload/Controllers/Op12Controller.cs +++ b/extra/admin-api/Spacebar.Offload/Controllers/Op12Controller.cs
diff --git a/extra/admin-api/Spacebar.GatewayOffload/Controllers/Op14Controller.cs b/extra/admin-api/Spacebar.Offload/Controllers/Op14Controller.cs
index 57f1390c..57f1390c 100644 --- a/extra/admin-api/Spacebar.GatewayOffload/Controllers/Op14Controller.cs +++ b/extra/admin-api/Spacebar.Offload/Controllers/Op14Controller.cs
diff --git a/extra/admin-api/Spacebar.GatewayOffload/Controllers/Op8Controller.cs b/extra/admin-api/Spacebar.Offload/Controllers/Op8Controller.cs
index ac68bb22..ac68bb22 100644 --- a/extra/admin-api/Spacebar.GatewayOffload/Controllers/Op8Controller.cs +++ b/extra/admin-api/Spacebar.Offload/Controllers/Op8Controller.cs
diff --git a/extra/admin-api/Spacebar.GatewayOffload/Extensions/Db/UserExtensions.cs b/extra/admin-api/Spacebar.Offload/Extensions/Db/UserExtensions.cs
index 27b4fb16..27b4fb16 100644 --- a/extra/admin-api/Spacebar.GatewayOffload/Extensions/Db/UserExtensions.cs +++ b/extra/admin-api/Spacebar.Offload/Extensions/Db/UserExtensions.cs
diff --git a/extra/admin-api/Spacebar.GatewayOffload/Program.cs b/extra/admin-api/Spacebar.Offload/Program.cs
index 947ca35f..947ca35f 100644 --- a/extra/admin-api/Spacebar.GatewayOffload/Program.cs +++ b/extra/admin-api/Spacebar.Offload/Program.cs
diff --git a/extra/admin-api/Spacebar.GatewayOffload/Properties/launchSettings.json b/extra/admin-api/Spacebar.Offload/Properties/launchSettings.json
index 385142c6..385142c6 100644 --- a/extra/admin-api/Spacebar.GatewayOffload/Properties/launchSettings.json +++ b/extra/admin-api/Spacebar.Offload/Properties/launchSettings.json
diff --git a/extra/admin-api/Spacebar.GatewayOffload/Spacebar.GatewayOffload.csproj b/extra/admin-api/Spacebar.Offload/Spacebar.Offload.csproj
index 8923cb36..8923cb36 100644 --- a/extra/admin-api/Spacebar.GatewayOffload/Spacebar.GatewayOffload.csproj +++ b/extra/admin-api/Spacebar.Offload/Spacebar.Offload.csproj
diff --git a/extra/admin-api/Spacebar.GatewayOffload/Spacebar.GatewayOffload.http b/extra/admin-api/Spacebar.Offload/Spacebar.Offload.http
index dc84f632..dc84f632 100644 --- a/extra/admin-api/Spacebar.GatewayOffload/Spacebar.GatewayOffload.http +++ b/extra/admin-api/Spacebar.Offload/Spacebar.Offload.http
diff --git a/extra/admin-api/Spacebar.GatewayOffload/appsettings.Development.json b/extra/admin-api/Spacebar.Offload/appsettings.Development.json
index 12d6d238..12d6d238 100644 --- a/extra/admin-api/Spacebar.GatewayOffload/appsettings.Development.json +++ b/extra/admin-api/Spacebar.Offload/appsettings.Development.json
diff --git a/extra/admin-api/Spacebar.GatewayOffload/appsettings.json b/extra/admin-api/Spacebar.Offload/appsettings.json
index 10f68b8c..10f68b8c 100644 --- a/extra/admin-api/Spacebar.GatewayOffload/appsettings.json +++ b/extra/admin-api/Spacebar.Offload/appsettings.json
diff --git a/extra/admin-api/Spacebar.GatewayOffload/deps.json b/extra/admin-api/Spacebar.Offload/deps.json
index b03c4aaa..b03c4aaa 100644 --- a/extra/admin-api/Spacebar.GatewayOffload/deps.json +++ b/extra/admin-api/Spacebar.Offload/deps.json
diff --git a/extra/admin-api/Spacebar.Offload/http-client.private.env.json b/extra/admin-api/Spacebar.Offload/http-client.private.env.json new file mode 100644
index 00000000..8e13c599 --- /dev/null +++ b/extra/admin-api/Spacebar.Offload/http-client.private.env.json
@@ -0,0 +1,5 @@ +{ + "dev": { + "AccessToken": "eyJhbGciOiJFUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjEwMDY1OTgyMzAxNTYzNDEyNzYiLCJpYXQiOjE3NjU4NjYxNDcsImtpZCI6IjVkZTcwNjZlNWQ5YTkxZDc4NGQ2NTY1Njc2Zjc0ZGY4NGQyMDllNzBjY2M3ZmZmNmFhNjgxNTkwODEwMWRjMWEiLCJ2ZXIiOjMsImRpZCI6IklCWkFSR01YT0UifQ.ALoB-4LXPaHTiUWRSoO3KIIc7CX2tP2vdebxmt10h3DqqBW57Zqx9zNImGxn0tV4cqFB1nZct3cZjJ_XVchtUF61AEgGR54QpV2sHAss2NMqZA_S3WK7UigFJYDddWUt2D_GrvzUYUVJ_WB4gt-tXekKzB2K6dazTEFYPFSY6xINBWed" + } +} \ No newline at end of file diff --git a/extra/admin-api/Spacebar.UApi/Program.cs b/extra/admin-api/Spacebar.UApi/Program.cs
index afdb42ae..3ebc2db5 100644 --- a/extra/admin-api/Spacebar.UApi/Program.cs +++ b/extra/admin-api/Spacebar.UApi/Program.cs
@@ -8,7 +8,6 @@ using Spacebar.ConfigModel.Extensions; using Spacebar.Interop.Authentication; using Spacebar.Interop.Authentication.AspNetCore; using Spacebar.Models.Db.Contexts; -using Spacebar.Models.Generic.Constants; using Spacebar.UApi.Services; var builder = WebApplication.CreateBuilder(args); @@ -114,7 +113,6 @@ app.Map("/", async context => { foreach (var header in responseMessage.Headers) context.Response.Headers[header.Key] = header.Value.ToArray(); foreach (var header in responseMessage.Content.Headers) context.Response.Headers[header.Key] = header.Value.ToArray(); - context.Response.Headers["X-SB-UApi-Status"] = "MISSING"; // await responseMessage.Content.CopyToAsync(context.Response.Body); var txt = await responseMessage.Content.ReadAsStringAsync(); diff --git a/extra/admin-api/SpacebarAdminAPI.slnx b/extra/admin-api/SpacebarAdminAPI.slnx
index 34ed5402..0578bc35 100644 --- a/extra/admin-api/SpacebarAdminAPI.slnx +++ b/extra/admin-api/SpacebarAdminAPI.slnx
@@ -36,6 +36,6 @@ </Folder> <Project Path="Spacebar.AdminApi/Spacebar.AdminApi.csproj" /> <Project Path="Spacebar.Cdn/Spacebar.Cdn.csproj" /> - <Project Path="Spacebar.GatewayOffload/Spacebar.GatewayOffload.csproj" /> + <Project Path="Spacebar.Offload/Spacebar.Offload.csproj" /> <Project Path="Spacebar.UApi/Spacebar.UApi.csproj" /> </Solution> diff --git a/extra/admin-api/outputs.nix b/extra/admin-api/outputs.nix
index 6f47df05..87f8e83e 100644 --- a/extra/admin-api/outputs.nix +++ b/extra/admin-api/outputs.nix
@@ -203,11 +203,11 @@ flake-utils.lib.eachSystem flake-utils.lib.allSystems ( proj.Spacebar-Interop-Cdn-Abstractions ]; }; - Spacebar-GatewayOffload = makeNupkg { - name = "Spacebar.GatewayOffload"; - nugetDeps = Spacebar.GatewayOffload/deps.json; - projectFile = "Spacebar.GatewayOffload.csproj"; - srcRoot = ./Spacebar.GatewayOffload; + Spacebar-Offload = makeNupkg { + name = "Spacebar.Offload"; + nugetDeps = Spacebar.Offload/deps.json; + projectFile = "Spacebar.Offload.csproj"; + srcRoot = ./Spacebar.Offload; packNupkg = false; projectReferences = [ proj.Spacebar-DataMappings-Generic @@ -258,30 +258,30 @@ flake-utils.lib.eachSystem flake-utils.lib.allSystems ( Expose = [ "5000" ]; }; }; - containers.docker.gateway-offload = pkgs.dockerTools.buildLayeredImage { - name = "spacebar-server-ts-gateway-offload"; - tag = builtins.replaceStrings [ "+" ] [ "_" ] self.packages.${system}.Spacebar-AdminApi.version; + containers.docker.offload = pkgs.dockerTools.buildLayeredImage { + name = "spacebar-server-ts-offload"; + tag = builtins.replaceStrings [ "+" ] [ "_" ] self.packages.${system}.Spacebar-Offload.version; contents = [ self.packages.${system}.Spacebar-AdminApi ]; config = { - Cmd = [ "${lib.getExe self.outputs.packages.${system}.Spacebar-GatewayOffload}" ]; + Cmd = [ "${lib.getExe self.outputs.packages.${system}.Spacebar-Offload}" ]; Expose = [ "5000" ]; }; }; containers.docker.cdn-cs = pkgs.dockerTools.buildLayeredImage { name = "spacebar-server-ts-cdn-cs"; - tag = builtins.replaceStrings [ "+" ] [ "_" ] self.packages.${system}.Spacebar-AdminApi.version; + tag = builtins.replaceStrings [ "+" ] [ "_" ] self.packages.${system}.Spacebar-Cdn.version; contents = [ self.packages.${system}.Spacebar-AdminApi ]; config = { - Cmd = [ "${lib.getExe self.outputs.packages.${system}.Spacebar-AdminApi}" ]; + Cmd = [ "${lib.getExe self.outputs.packages.${system}.Spacebar-Cdn}" ]; Expose = [ "5000" ]; }; }; containers.docker.uapi = pkgs.dockerTools.buildLayeredImage { name = "spacebar-server-ts-cdn-cs"; - tag = builtins.replaceStrings [ "+" ] [ "_" ] self.packages.${system}.Spacebar-AdminApi.version; + tag = builtins.replaceStrings [ "+" ] [ "_" ] self.packages.${system}.Spacebar-UApi.version; contents = [ self.packages.${system}.Spacebar-AdminApi ]; config = { - Cmd = [ "${lib.getExe self.outputs.packages.${system}.Spacebar-AdminApi}" ]; + Cmd = [ "${lib.getExe self.outputs.packages.${system}.Spacebar-UApi}" ]; Expose = [ "5000" ]; }; }; @@ -295,7 +295,7 @@ flake-utils.lib.eachSystem flake-utils.lib.allSystems ( in pkgs.lib.recursiveUpdate (pkgs.lib.attrsets.unionOfDisjoint { } self.packages) { x86_64-linux = { - # spacebar-server-tests = self.packages.x86_64-linux.default.passthru.tests; + # spacebar-server-tests = self.packages.x86_64-linux.default.passthru.tests; docker-admin-api = self.containers.x86_64-linux.docker.admin-api; docker-gateway-offload = self.containers.x86_64-linux.docker.gateway-offload; docker-cdn-cs = self.containers.x86_64-linux.docker.cdn-cs; diff --git a/nix/modules/default/cs/gateway-offload-cs.nix b/nix/modules/default/cs/gateway-offload-cs.nix deleted file mode 100644
index 6187f075..00000000 --- a/nix/modules/default/cs/gateway-offload-cs.nix +++ /dev/null
@@ -1,89 +0,0 @@ -self: -{ - config, - lib, - pkgs, - spacebar, - ... -}: - -let - secrets = import ../secrets.nix { inherit lib config; }; - cfg = config.services.spacebarchat-server; - jsonFormat = pkgs.formats.json { }; -in -{ - imports = [ ]; - options.services.spacebarchat-server.gatewayOffload = lib.mkOption { - default = { }; - description = "Configuration for C# gateway offload daemon."; - type = lib.types.submodule { - options = { - enable = lib.mkEnableOption "Enable gateway offload daemon (C#)."; - listenPort = lib.mkOption { - type = lib.types.port; - default = 3011; - description = "Port for the gateway offload daemon to listen on."; - }; - extraConfiguration = lib.mkOption { - type = jsonFormat.type; - default = import ./default-appsettings-json.nix; - description = "Extra appsettings.json configuration for the gateway offload daemon."; - }; - enableIdentify = lib.mkEnableOption "Enable offloading gateway opcode 2 (IDENTIFY)."; - enableGuildMembers = lib.mkEnableOption "Enable offloading gateway opcode 8 (REQUEST_GUILD_MEMBERS)."; - enableGuildSync = lib.mkEnableOption "Enable offloading gateway opcode 12 (GUILD_SYNC)."; - enableLazyRequest = lib.mkEnableOption "Enable offloading gateway opcode 14 (LAZY_REQUEST)."; - enableChannelStatuses = lib.mkEnableOption "Enable offloading gateway opcode 36 (CHANNEL_STATUSES)."; - enableChannelInfo = lib.mkEnableOption "Enable offloading gateway opcode 43 (CHANNEL_INFO)."; - }; - }; - }; - - config = lib.mkIf cfg.gatewayOffload.enable ( - let - makeServerTsService = import ../makeServerTsService.nix { inherit cfg lib secrets; }; - in - { - assertions = [ - (import ./assert-has-connection-string.nix "Gateway Offload" cfg.gatewayOffload.extraConfiguration) - ]; - - services.spacebarchat-server.settings.offload = { - gateway = { - identifyUrl = lib.mkIf cfg.gatewayOffload.enableIdentify "http://127.0.0.1:${builtins.toString cfg.gatewayOffload.listenPort}/_spacebar/offload/gateway/Identify"; - guildMembersUrl = lib.mkIf cfg.gatewayOffload.enableGuildMembers "http://127.0.0.1:${builtins.toString cfg.gatewayOffload.listenPort}/_spacebar/offload/gateway/GuildMembers"; - guildSyncUrlUrl = lib.mkIf cfg.gatewayOffload.enableGuildSync "http://127.0.0.1:${builtins.toString cfg.gatewayOffload.listenPort}/_spacebar/offload/gateway/GuildSync"; - lazyRequestUrl = lib.mkIf cfg.gatewayOffload.enableLazyRequest "http://127.0.0.1:${builtins.toString cfg.gatewayOffload.listenPort}/_spacebar/offload/gateway/LazyRequest"; - channelStatusesUrl = lib.mkIf cfg.gatewayOffload.enableChannelStatuses "http://127.0.0.1:${builtins.toString cfg.gatewayOffload.listenPort}/_spacebar/offload/gateway/ChannelStatuses"; - channelInfoUrl = lib.mkIf cfg.gatewayOffload.enableChannelInfo "http://127.0.0.1:${builtins.toString cfg.gatewayOffload.listenPort}/_spacebar/offload/gateway/ChannelInfo"; - }; - }; - - systemd.services.spacebar-cs-gateway-offload = makeServerTsService { - description = "Spacebar Server - C# Gateway offload"; - environment = builtins.mapAttrs (_: val: builtins.toString val) ( - { - # things we set by default... - EVENT_TRANSMISSION = "unix"; - EVENT_SOCKET_PATH = "/run/spacebar/"; - } - // cfg.extraEnvironment - // { - # things we force... - # CONFIG_PATH = configFile; - CONFIG_READONLY = 1; - ASPNETCORE_URLS = "http://0.0.0.0:${toString cfg.gatewayOffload.listenPort}"; - STORAGE_LOCATION = cfg.cdnPath; - APPSETTINGS_PATH = jsonFormat.generate "appsettings.spacebar-gateway-offload.json" ( - lib.recursiveUpdate (import ./default-appsettings-json.nix) cfg.gatewayOffload.extraConfiguration - ); - } - ); - serviceConfig = { - ExecStart = "${self.packages.${pkgs.stdenv.hostPlatform.system}.Spacebar-GatewayOffload}/bin/Spacebar.GatewayOffload"; - }; - }; - } - ); -} diff --git a/nix/modules/default/cs/offload-cs.nix b/nix/modules/default/cs/offload-cs.nix new file mode 100644
index 00000000..9186edcb --- /dev/null +++ b/nix/modules/default/cs/offload-cs.nix
@@ -0,0 +1,97 @@ +self: +{ + config, + lib, + pkgs, + spacebar, + ... +}: + +let + secrets = import ../secrets.nix { inherit lib config; }; + cfg = config.services.spacebarchat-server; + offloadCfg = cfg.offload; + jsonFormat = pkgs.formats.json { }; +in +{ + imports = [ ]; + options.services.spacebarchat-server.offload = lib.mkOption { + default = { }; + description = "Configuration for C# offload daemon."; + type = lib.types.submodule { + options = { + enable = lib.mkEnableOption "Enable offload daemon (C#)."; + listenPort = lib.mkOption { + type = lib.types.port; + default = 3011; + description = "Port for the offload daemon to listen on."; + }; + extraConfiguration = lib.mkOption { + type = jsonFormat.type; + default = import ./default-appsettings-json.nix; + description = "Extra appsettings.json configuration for the offload daemon."; + }; + gateway = lib.mkOption { + description = "Gateway offloads"; + type = lib.types.submodule { + options = { + enableIdentify = lib.mkEnableOption "Enable offloading gateway opcode 2 (IDENTIFY)."; + enableGuildMembers = lib.mkEnableOption "Enable offloading gateway opcode 8 (REQUEST_GUILD_MEMBERS)."; + enableGuildSync = lib.mkEnableOption "Enable offloading gateway opcode 12 (GUILD_SYNC)."; + enableLazyRequest = lib.mkEnableOption "Enable offloading gateway opcode 14 (LAZY_REQUEST)."; + enableChannelStatuses = lib.mkEnableOption "Enable offloading gateway opcode 36 (CHANNEL_STATUSES)."; + enableChannelInfo = lib.mkEnableOption "Enable offloading gateway opcode 43 (CHANNEL_INFO)."; + }; + }; + }; + }; + }; + }; + + config = lib.mkIf offloadCfg.enable ( + let + makeServerTsService = import ../makeServerTsService.nix { inherit cfg lib secrets; }; + in + { + assertions = [ + (import ./assert-has-connection-string.nix "Gateway Offload" offloadCfg.extraConfiguration) + ]; + + services.spacebarchat-server.settings.offload = { + gateway = { + identifyUrl = lib.mkIf offloadCfg.gateway.enableIdentify "http://127.0.0.1:${builtins.toString offloadCfg.listenPort}/_spacebar/offload/gateway/Identify"; + guildMembersUrl = lib.mkIf offloadCfg.gateway.enableGuildMembers "http://127.0.0.1:${builtins.toString offloadCfg.listenPort}/_spacebar/offload/gateway/GuildMembers"; + guildSyncUrlUrl = lib.mkIf offloadCfg.gateway.enableGuildSync "http://127.0.0.1:${builtins.toString offloadCfg.listenPort}/_spacebar/offload/gateway/GuildSync"; + lazyRequestUrl = lib.mkIf offloadCfg.gateway.enableLazyRequest "http://127.0.0.1:${builtins.toString offloadCfg.listenPort}/_spacebar/offload/gateway/LazyRequest"; + channelStatusesUrl = lib.mkIf offloadCfg.gateway.enableChannelStatuses "http://127.0.0.1:${builtins.toString offloadCfg.listenPort}/_spacebar/offload/gateway/ChannelStatuses"; + channelInfoUrl = lib.mkIf offloadCfg.gateway.enableChannelInfo "http://127.0.0.1:${builtins.toString offloadCfg.listenPort}/_spacebar/offload/gateway/ChannelInfo"; + }; + }; + + systemd.services.spacebar-cs-offload = makeServerTsService { + description = "Spacebar Server - C# offload"; + environment = builtins.mapAttrs (_: val: builtins.toString val) ( + { + # things we set by default... + EVENT_TRANSMISSION = "unix"; + EVENT_SOCKET_PATH = "/run/spacebar/"; + } + // cfg.extraEnvironment + // { + # things we force... + # CONFIG_PATH = configFile; + CONFIG_READONLY = 1; + ASPNETCORE_URLS = "http://0.0.0.0:${toString offloadCfg.listenPort}"; + STORAGE_LOCATION = cfg.cdnPath; + APPSETTINGS_PATH = jsonFormat.generate "appsettings.spacebar-offload.json" ( + lib.recursiveUpdate (import ./default-appsettings-json.nix) offloadCfg.extraConfiguration + ); + } + ); + serviceConfig = { + ExecStart = "${lib.getExe self.packages.${pkgs.stdenv.hostPlatform.system}.Spacebar-Offload}"; + }; + }; + } + ); +} diff --git a/nix/modules/default/default.nix b/nix/modules/default/default.nix
index 001cdc74..fefb25ce 100644 --- a/nix/modules/default/default.nix +++ b/nix/modules/default/default.nix
@@ -20,7 +20,7 @@ in (import ./gw-sharding.nix self) (import ./pion-sfu.nix self) (import ./cs/cdn-cs.nix self) - (import ./cs/gateway-offload-cs.nix self) + (import ./cs/offload-cs.nix self) (import ./cs/admin-api.nix self) (import ./cs/uapi.nix self) ]; diff --git a/nix/testVm/configuration.nix b/nix/testVm/configuration.nix
index 10bee8ec..f9df7426 100644 --- a/nix/testVm/configuration.nix +++ b/nix/testVm/configuration.nix
@@ -31,7 +31,7 @@ in enable = true; apiEndpoint = sbLib.mkEndpointRaw "api.sb.localhost" 3001 8080 false; gatewayEndpoint = sbLib.mkEndpointRaw "gw.sb.localhost" 3002 8080 false; - extraGatewayPorts = lib.range 3100 3116; + extraGatewayPorts = lib.range 3100 3103; # 4 gateways total cdnEndpoint = sbLib.mkEndpointRaw "cdn.sb.localhost" 3003 8080 false; adminApiEndpoint = sbLib.mkEndpointRaw "admin.sb.localhost" 3004 8080 false; webrtcEndpoint = sbLib.mkEndpointRaw "voice.sb.localhost" 3005 8080 false; @@ -45,16 +45,24 @@ in cdnSignatureIncludeUserAgent = false; cdnSignatureKey = "meow"; }; + limits = { + absoluteRate = { + register.enabled = false; + sendMessage.enabled = false; + }; + }; }; - gatewayOffload = { + offload = { enable = true; - enableIdentify = true; - enableGuildMembers = true; - enableGuildSync = true; - enableLazyRequest = true; - enableChannelStatuses = true; - enableChannelInfo = true; + gateway = { + enableIdentify = true; + enableGuildMembers = true; + enableGuildSync = true; + enableLazyRequest = true; + enableChannelStatuses = true; + enableChannelInfo = true; + }; extraConfiguration.ConnectionStrings.Spacebar = csConnectionString; }; @@ -62,7 +70,7 @@ in enable = true; extraConfiguration.ConnectionStrings.Spacebar = csConnectionString; }; - + cdnCs = { enable = false; extraConfiguration.ConnectionStrings.Spacebar = csConnectionString; @@ -80,7 +88,7 @@ in extraEnvironment = { DATABASE = "postgres://postgres:postgres@127.0.0.1/spacebar"; -# LOG_REQUESTS = "-200,204,304"; + # LOG_REQUESTS = "-200,204,304"; LOG_REQUESTS = "-"; LOG_VALIDATION_ERRORS = true; #DB_LOGGING=true; @@ -93,6 +101,13 @@ in in lib.trace ("Testing with config: " + builtins.toJSON cfg) cfg; services.nginx.enable = true; + services.nginx.recommendedOptimisation = true; + services.nginx.appendConfig = '' + worker_processes 6; + ''; + services.nginx.eventsConfig = '' + worker_connections 512; + ''; users.users.root.initialPassword = "root"; services.getty.autologinUser = "root"; diff --git a/nix/tests/test-bundle-starts.nix b/nix/tests/test-bundle-starts.nix
index 3beedaae..16134f91 100644 --- a/nix/tests/test-bundle-starts.nix +++ b/nix/tests/test-bundle-starts.nix
@@ -30,9 +30,11 @@ in }; nginx.enable = true; - gatewayOffload = { + offload = { enable = true; - enableGuildSync = true; + gateway = { + enableGuildSync = true; + }; extraConfiguration.ConnectionStrings.Spacebar = "Host=127.0.0.1; Username=Spacebar; Password=postgres; Database=spacebar; Port=5432; Include Error Detail=true; Maximum Pool Size=1000; Command Timeout=6000; Timeout=600;"; }; };