Skip to content

Commit

Permalink
Added Restart workflow
Browse files Browse the repository at this point in the history
Events will ignore exceptions
  • Loading branch information
Aragas committed Sep 5, 2024
1 parent 9daf835 commit fb17c27
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 9 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/restart.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: "Restart 'P3D Legacy Server'"

on:
workflow_dispatch:

jobs:
restart:
name: "Restart 'P3D Legacy Server'"
runs-on: ubuntu-latest
steps:
- uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
port: ${{ secrets.PORT }}
script: |
docker service update --force p3dlegacyserver_p3d_legacy_server;
- name: Checkout Repository
if: always()
uses: actions/checkout@v4

- name: Notify
if: always()
env:
BUILD_STATUS: ${{ job.status }}
WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_QA }}
run: bash ./.github/workflows/discord.sh
10 changes: 5 additions & 5 deletions src/P3D.Legacy.Server.Abstractions/Options/ServerOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ public ServerOptionsValidator()

public sealed record ServerOptions
{
public required string Name { get; init; } = default!;
public required string Message { get; init; } = default!;
public required int MaxPlayers { get; init; } = default!;
public required bool OfflineEnabled { get; init; } = default!;
public required bool ValidationEnabled { get; init; } = default!;
public string Name { get; init; } = default!;
public string Message { get; init; } = default!;
public int MaxPlayers { get; init; } = default!;
public bool OfflineEnabled { get; init; } = default!;
public bool ValidationEnabled { get; init; } = default!;
}
}
12 changes: 11 additions & 1 deletion src/P3D.Legacy.Server.CQERS/Events/ReceiveContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,17 @@ public Task PublishAsync(IEvent @event, DispatchStrategy strategy, CancellationT

private Task ParallelWhenAllAsync(IEnumerable<EventHandler> handlers, IEvent @event, CancellationToken ct)
{
return Task.WhenAll(handlers.Select(handler => handler(@event, ct)));
return Task.WhenAll(handlers.Select(async handler =>
{
try
{
await handler(@event, ct);
}
catch (Exception e)
{
ExceptionDuringPublish(nameof(DispatchStrategy.ParallelWhenAll), e);
}
}));
}

private Task ParallelWhenAnyAsync(IEnumerable<EventHandler> handlers, IEvent @event, CancellationToken ct)
Expand Down
13 changes: 10 additions & 3 deletions src/P3D.Legacy.Server/Options/OtlpOptions.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
using Aragas.Extensions.Options.FluentValidation.Extensions;

using FluentValidation;
using OpenTelemetry.Exporter;

namespace P3D.Legacy.Server.Options
{
public sealed class OtlpOptionsValidator : AbstractValidator<OtlpOptions>
{
public OtlpOptionsValidator()
{
RuleFor(static x => x.Host).IsUri().IsUrlTcpEndpointAvailable().When(static x => x.Enabled);
RuleFor(static x => x.LoggingEndpoint).IsUri().IsUrlTcpEndpointAvailable().When(static x => !string.IsNullOrEmpty(x.LoggingEndpoint));
RuleFor(static x => x.TracingEndpoint).IsUri().IsUrlTcpEndpointAvailable().When(static x => !string.IsNullOrEmpty(x.TracingEndpoint));
RuleFor(static x => x.MetricsEndpoint).IsUri().IsUrlTcpEndpointAvailable().When(static x => !string.IsNullOrEmpty(x.MetricsEndpoint));
}
}

public sealed record OtlpOptions
{
public required bool Enabled { get; init; } = default!;
public required string Host { get; init; } = default!;
public required string LoggingEndpoint { get; init; } = default!;
public required OtlpExportProtocol LoggingProtocol { get; init; } = default!;
public required string TracingEndpoint { get; init; } = default!;
public required OtlpExportProtocol TracingProtocol { get; init; } = default!;
public required string MetricsEndpoint { get; init; } = default!;
public required OtlpExportProtocol MetricsProtocol { get; init; } = default!;
}
}

0 comments on commit fb17c27

Please sign in to comment.