From ce6a9863bd5824e326b8760576fc1c67c8129894 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 22 Nov 2025 15:28:14 -0600 Subject: add mirror workflow --- .github/workflows/mirror.yml | 87 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 .github/workflows/mirror.yml diff --git a/.github/workflows/mirror.yml b/.github/workflows/mirror.yml new file mode 100644 index 00000000..d20d0e2c --- /dev/null +++ b/.github/workflows/mirror.yml @@ -0,0 +1,87 @@ +name: Mirror Repository + +on: + push: + branches: + - '**' # Trigger on push to any branch + delete: + branches: + - '**' # Trigger when branches are deleted + +jobs: + mirror: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Fetch full history for proper mirroring + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Configure SSH + env: + SSH_KEY: ${{ secrets.GIT_MIRROR_SSH_KEY }} + run: | + if [ -z "$SSH_KEY" ]; then + echo "⚠️ SSH key not configured. Skipping mirror sync." + echo "Please set GIT_MIRROR_SSH_KEY secret to enable mirroring." + exit 1 + fi + + # Set up SSH key + mkdir -p ~/.ssh + echo "$SSH_KEY" > ~/.ssh/id_ed25519 + chmod 600 ~/.ssh/id_ed25519 + + # Add known hosts to avoid SSH prompts + ssh-keyscan gitlab.com >> ~/.ssh/known_hosts + ssh-keyscan codeberg.org >> ~/.ssh/known_hosts + + # Configure Git + git config --global user.name "GitHub Actions" + git config --global user.email "actions@github.com" + + - name: Mirror to GitLab + run: | + echo "🔄 Syncing to GitLab..." + # Add GitLab remote with SSH + git remote add gitlab git@gitlab.com:slskd/slskd.git + + # Push all branches and tags to GitLab + git push gitlab --all --force + git push gitlab --tags --force + + echo "✅ Successfully synced to GitLab" + + - name: Mirror to Codeberg + run: | + echo "🔄 Syncing to Codeberg..." + # Add Codeberg remote with SSH + git remote add codeberg git@codeberg.org:slskd/slskd.git + + # Push all branches and tags to Codeberg + git push codeberg --all --force + git push codeberg --tags --force + + echo "✅ Successfully synced to Codeberg" + + - name: Handle branch deletion + if: github.event_name == 'delete' && github.event.ref_type == 'branch' + run: | + DELETED_BRANCH="${{ github.event.ref }}" + echo "🗑️ Branch '$DELETED_BRANCH' was deleted, syncing deletion to mirrors..." + + # Delete branch from GitLab + git push git@gitlab.com:slskd/slskd.git --delete "$DELETED_BRANCH" || echo "Branch may not exist on GitLab" + + # Delete branch from Codeberg + git push git@codeberg.org:slskd/slskd.git --delete "$DELETED_BRANCH" || echo "Branch may not exist on Codeberg" + + - name: Summary + run: | + echo "🎉 Repository mirroring completed!" + echo "📊 Summary:" + echo " - GitHub: ✅ Source repository" + echo " - GitLab: ✅ Synced" + echo " - Codeberg: ✅ Synced" \ No newline at end of file -- cgit v1.2.3 From fc90283449792f87479534d32edb5cc3e9f77790 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 22 Nov 2025 15:41:32 -0600 Subject: use a matrix --- .github/workflows/mirror.yml | 69 +++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 39 deletions(-) diff --git a/.github/workflows/mirror.yml b/.github/workflows/mirror.yml index d20d0e2c..7a52415b 100644 --- a/.github/workflows/mirror.yml +++ b/.github/workflows/mirror.yml @@ -11,7 +11,17 @@ on: jobs: mirror: runs-on: ubuntu-latest - + strategy: + matrix: + target: + - name: GitLab + host: gitlab.com + repo: git@gitlab.com:slskd/slskd.git + - name: Codeberg + host: codeberg.org + repo: git@codeberg.org:slskd/slskd.git + fail-fast: false # Continue with other mirrors even if one fails + steps: - name: Checkout repository uses: actions/checkout@v4 @@ -34,54 +44,35 @@ jobs: echo "$SSH_KEY" > ~/.ssh/id_ed25519 chmod 600 ~/.ssh/id_ed25519 - # Add known hosts to avoid SSH prompts - ssh-keyscan gitlab.com >> ~/.ssh/known_hosts - ssh-keyscan codeberg.org >> ~/.ssh/known_hosts + # Start SSH agent and add key + eval "$(ssh-agent -s)" + ssh-add ~/.ssh/id_ed25519 + + # Add known host to avoid SSH prompts + ssh-keyscan ${{ matrix.target.host }} >> ~/.ssh/known_hosts # Configure Git git config --global user.name "GitHub Actions" git config --global user.email "actions@github.com" - - name: Mirror to GitLab + - name: Mirror to ${{ matrix.target.name }} + if: github.event_name != 'delete' run: | - echo "🔄 Syncing to GitLab..." - # Add GitLab remote with SSH - git remote add gitlab git@gitlab.com:slskd/slskd.git - - # Push all branches and tags to GitLab - git push gitlab --all --force - git push gitlab --tags --force + echo "🔄 Syncing to ${{ matrix.target.name }}..." + # Add remote with SSH + git remote add mirror ${{ matrix.target.repo }} - echo "✅ Successfully synced to GitLab" - - - name: Mirror to Codeberg - run: | - echo "🔄 Syncing to Codeberg..." - # Add Codeberg remote with SSH - git remote add codeberg git@codeberg.org:slskd/slskd.git + # Push all branches and tags + git push mirror --all --force + git push mirror --tags --force - # Push all branches and tags to Codeberg - git push codeberg --all --force - git push codeberg --tags --force + echo "✅ Successfully synced to ${{ matrix.target.name }}" - echo "✅ Successfully synced to Codeberg" - - - name: Handle branch deletion + - name: Handle branch deletion on ${{ matrix.target.name }} if: github.event_name == 'delete' && github.event.ref_type == 'branch' run: | DELETED_BRANCH="${{ github.event.ref }}" - echo "🗑️ Branch '$DELETED_BRANCH' was deleted, syncing deletion to mirrors..." - - # Delete branch from GitLab - git push git@gitlab.com:slskd/slskd.git --delete "$DELETED_BRANCH" || echo "Branch may not exist on GitLab" + echo "🗑️ Branch '$DELETED_BRANCH' was deleted, syncing deletion to ${{ matrix.target.name }}..." - # Delete branch from Codeberg - git push git@codeberg.org:slskd/slskd.git --delete "$DELETED_BRANCH" || echo "Branch may not exist on Codeberg" - - - name: Summary - run: | - echo "🎉 Repository mirroring completed!" - echo "📊 Summary:" - echo " - GitHub: ✅ Source repository" - echo " - GitLab: ✅ Synced" - echo " - Codeberg: ✅ Synced" \ No newline at end of file + # Delete branch from mirror + git push ${{ matrix.target.repo }} --delete "$DELETED_BRANCH" || echo "Branch may not exist on ${{ matrix.target.name }}" \ No newline at end of file -- cgit v1.2.3 From 277fed8cdd5187769479eed60754b300b96761eb Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 22 Nov 2025 17:33:00 -0600 Subject: add flag to enable logging of unobserved exceptions --- config/slskd.example.yml | 1 + src/slskd/Core/Options.cs | 9 +++++++++ src/slskd/Program.cs | 15 +++++++++------ 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/config/slskd.example.yml b/config/slskd.example.yml index 419c0c9f..a0ca4f3f 100644 --- a/config/slskd.example.yml +++ b/config/slskd.example.yml @@ -13,6 +13,7 @@ # force_migrations: false # no_version_check: false # log_sql: false +# log_unobserved_exceptions: false # experimental: false # volatile: false # case_sensitive_reg_ex: false diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index 61e2878c..ec94afcb 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -417,6 +417,15 @@ namespace slskd [RequiresRestart] public bool LogSQL { get; init; } = false; + /// + /// Gets a value indicating whether to log unobserved Exceptions. + /// + [Argument(default, "log-unobserved-exceptions")] + [EnvironmentVariable("LOG_UNOBSERVED_EXCEPTIONS")] + [Description("log unobserved exceptions (caution: verbose)")] + [RequiresRestart] + public bool LogUnobservedExceptions { get; init; } = false; + /// /// Gets a value indicating whether the application should run in experimental mode. /// diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs index ee9e2d0c..07d08fca 100644 --- a/src/slskd/Program.cs +++ b/src/slskd/Program.cs @@ -1143,12 +1143,15 @@ namespace slskd })) .CreateLogger(); - // // occurs when a faulted task's unobserved exception is about to trigger exception escalation policy, which, by default, would terminate the process. - // TaskScheduler.UnobservedTaskException += (sender, e) => - // { - // Serilog.Log.Logger.Error(e.Exception, "Unobserved exception: {Message}", e.Exception.Message); - // e.SetObserved(); - // }; + if (OptionsAtStartup.Flags.LogUnobservedExceptions) + { + // log Exceptions raised on fired-and-forgotten tasks, which adds very little value but might help debug someday + TaskScheduler.UnobservedTaskException += (sender, e) => + { + Serilog.Log.Logger.Error(e.Exception, "Unobserved exception: {Message}", e.Exception.Message); + e.SetObserved(); + }; + } AppDomain.CurrentDomain.UnhandledException += (sender, e) => { -- cgit v1.2.3 From 8b6a9a3108a20b280f2891e47d30ecb931d9a435 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 22 Nov 2025 17:35:38 -0600 Subject: docs for unobserved exception flag --- docs/config.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/config.md b/docs/config.md index 5a4d3155..2646dd94 100644 --- a/docs/config.md +++ b/docs/config.md @@ -1266,6 +1266,7 @@ Several additional feature flags are provided to change the application's runtim | `--force-migrations` | `SLSKD_FORCE_MIGRATIONS` | Force database migrations to be applied on startup | | `--no-version-check` | `SLSKD_NO_VERSION_CHECK` | Don't perform a version check on startup | | `--log-sql` | `SLSKD_LOG_SQL` | Log SQL queries generated by Entity Framework | +| `--log-unobserved-exceptions` | `SLSKD_LOG_UNOBSERVED_EXCEPTIONS` | Log unobserved Exceptions (caution: verbose) | | `--volatile` | `SLSKD_VOLATILE` | Use volatile data storage (all data will be lost at shutdown) | | `--case-sensitive-regex` | `SLSKD_CASE_SENSITIVE_REGEX` | User-defined regular expressions are case sensitive | | `--legacy-windows-tcp-keepalive` | `SLSKD_LEGACY_WINDOWS_TCP_KEEPALIVE` | Use a legacy TCP keepalive strategy for older Windows versions | -- cgit v1.2.3 From 99207f0957f4597a36e56483560c67dc68f4d00a Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 22 Nov 2025 17:40:26 -0600 Subject: fix build warnings --- src/slskd/Events/Types/Events.cs | 1 + src/slskd/Telemetry/API/TelemetryController.cs | 2 +- src/slskd/Telemetry/TelemetryService.cs | 2 +- src/slskd/Telemetry/Types/PrometheusMetric.cs | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/slskd/Events/Types/Events.cs b/src/slskd/Events/Types/Events.cs index 6e99b800..577e41e3 100644 --- a/src/slskd/Events/Types/Events.cs +++ b/src/slskd/Events/Types/Events.cs @@ -28,6 +28,7 @@ public enum EventType DownloadFileComplete = 2, DownloadDirectoryComplete = 3, UploadFileComplete = 4, + // UploadDirectoryComplete = 5, PrivateMessageReceived = 6, RoomMessageReceived = 7, diff --git a/src/slskd/Telemetry/API/TelemetryController.cs b/src/slskd/Telemetry/API/TelemetryController.cs index 2207ac8c..d5c44c1a 100644 --- a/src/slskd/Telemetry/API/TelemetryController.cs +++ b/src/slskd/Telemetry/API/TelemetryController.cs @@ -57,7 +57,7 @@ public class TelemetryController : ControllerBase /// * node_filesystem_avail_bytes = how much space is left on the system /// * node_network = info about network adapters on the system /// Other - /// * process_start_time_seconds = unix timestamp of start time + /// * process_start_time_seconds = unix timestamp of start time. /// private List KpiRegexes { get; } = new List { diff --git a/src/slskd/Telemetry/TelemetryService.cs b/src/slskd/Telemetry/TelemetryService.cs index c3d66196..1c124610 100644 --- a/src/slskd/Telemetry/TelemetryService.cs +++ b/src/slskd/Telemetry/TelemetryService.cs @@ -1,4 +1,4 @@ -// +// // Copyright (c) slskd Team. All rights reserved. // // This program is free software: you can redistribute it and/or modify diff --git a/src/slskd/Telemetry/Types/PrometheusMetric.cs b/src/slskd/Telemetry/Types/PrometheusMetric.cs index 53b8dc10..93ca6422 100644 --- a/src/slskd/Telemetry/Types/PrometheusMetric.cs +++ b/src/slskd/Telemetry/Types/PrometheusMetric.cs @@ -1,4 +1,4 @@ -// +// // Copyright (c) slskd Team. All rights reserved. // // This program is free software: you can redistribute it and/or modify -- cgit v1.2.3