Пример #1
0
    protected override async Task OnExecute(CancellationToken ct)
    {
        var upcomingRestarts = await _mediator.Send(new GetUpcoming.Query(), ct);

        foreach (var(serverId, job) in upcomingRestarts)
        {
            var server = _ps.GetOnlineServerOrDefault(serverId);

            if (server is null)
            {
                _logger.LogWarning("Server {ServerId} scheduled to restart was already offline", serverId);
                return;
            }

            await _mediator.Send(new Notify.Command(server, job.NextExecution !.Value - DateTime.UtcNow), ct);
        }
    }