Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Build
on:
push:
paths:
- "lib/**"
- "services/**"
- ".github/workflows/build.yml"

Expand Down
34 changes: 33 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "Grid.Bot",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"preLaunchTask": "build: grid-bot",
"program": "${workspaceFolder}/services/grid-bot/src/bin/Debug/net8.0/Grid.Bot.dll",
"cwd": "${workspaceFolder}/services/grid-bot/src/",
"console": "internalConsole",
Expand All @@ -31,6 +31,38 @@
},
"requireExactSource": false,
"envFile": "${workspaceFolder}/.env"
},

{
"name": "Grid.Bot.Recovery",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build: grid-bot-recovery",
"program": "${workspaceFolder}/services/recovery/src/bin/Debug/net8.0/Grid.Bot.Recovery.dll",
"cwd": "${workspaceFolder}/services/recovery/src/",
"console": "internalConsole",
"stopAtEntry": false,
"justMyCode": true,
"logging": {
"moduleLoad": false
},
"requireExactSource": false,
"envFile": "${workspaceFolder}/.env"
},
{
"name": "Grid.Bot.Recovery (No build)",
"type": "coreclr",
"request": "launch",
"program": "${workspaceFolder}/services/recovery/src/bin/Debug/net8.0/Grid.Bot.Recovery.dll",
"cwd": "${workspaceFolder}/services/recovery/src/",
"console": "internalConsole",
"stopAtEntry": false,
"justMyCode": true,
"logging": {
"moduleLoad": false
},
"requireExactSource": false,
"envFile": "${workspaceFolder}/.env"
}
]
}
16 changes: 15 additions & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"version": "2.0.0",
"tasks": [
{
"label": "build",
"label": "build: grid-bot",
"command": "dotnet",
"type": "process",
"args": [
Expand All @@ -14,6 +14,20 @@
"/p:Platform=AnyCPU",
],
"problemMatcher": "$msCompile"
},
{
"label": "build: grid-bot-recovery",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/services/recovery/src/Grid.Bot.Recovery.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary",
"/p:Configuration=Debug",
"/p:Platform=AnyCPU",
],
"problemMatcher": "$msCompile"
}
]
}
10 changes: 10 additions & 0 deletions services/grid-bot/.component.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ deployment:
- "traefik.http.routers.${{ env.NOMAD_ENVIRONMENT }}-grid-bot-web.rule=(Host(`clientsettingscdn.sitetest4.robloxlabs.com`) || Host(`versioncompatibility.api.sitetest4.robloxlabs.com`) || Host(`avatar.sitetest4.robloxlabs.com`))"
- "traefik.http.routers.${{ env.NOMAD_ENVIRONMENT }}-grid-bot-web.entrypoints=http,https"

- name: ${{ env.NOMAD_ENVIRONMENT }}-grid-bot-grpc
port: grpc
tags:
- ${{ env.NOMAD_ENVIRONMENT }}

- "traefik.enable=true"
- "traefik.http.routers.${{ env.NOMAD_ENVIRONMENT }}-grid-bot-grpc.rule=Host(`grid-bot-grpc.wck02.vmminfra.dev`)"
- "traefik.http.routers.${{ env.NOMAD_ENVIRONMENT }}-grid-bot-grpc.entrypoints=https"
- "traefik.http.services.${{ env.NOMAD_ENVIRONMENT }}-grid-bot-grpc.loadbalancer.server.scheme=h2c"

volumes:
- '/var/run/docker.sock:/var/run/docker.sock'
- '/tmp/.X11-unix:/tmp/.X11-unix'
Expand Down
13 changes: 4 additions & 9 deletions services/recovery/src/Events/OnReady.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class OnShardReady(
OnInteraction onInteractionEvent
)
{
private Atomic<int> _shardCount = 0; // needs to be atomic due to the race situation here.
private OnceFlag _readyFlag = new();

private readonly ISettings _settings = settings ?? throw new ArgumentNullException(nameof(settings));
private readonly ILogger _logger = logger ?? throw new ArgumentNullException(nameof(logger));
Expand All @@ -54,30 +54,25 @@ private static string GetStatusText(string updateText)
/// <param name="shard">The client for the shard.</param>
public Task Invoke(DiscordSocketClient shard)
{
_shardCount++;

_logger.Debug(
"Shard '{0}' ready as '{0}#{1}'",
shard.ShardId,
_client.CurrentUser.Username,
_client.CurrentUser.Discriminator
);

if (_shardCount == _client.Shards.Count)
{
_shardCount = 0;

_logger.Debug("Final shard ready!");

Call.Once(ref _readyFlag, () =>
{
_client.MessageReceived += _onMessageEvent.Invoke;
_client.InteractionCreated += _onInteractionEvent.Invoke;

var text = _settings.MaintenanceStatusMessage;

_client.SetStatusAsync(UserStatus.DoNotDisturb);
_client.SetGameAsync(GetStatusText(text));
});

}

return Task.CompletedTask;
}
Expand Down
Loading