From 04b0c305edd848500e149608b8a4be06e9d4f1d6 Mon Sep 17 00:00:00 2001 From: Abdullah Atta Date: Sat, 2 May 2026 22:18:34 +0500 Subject: [PATCH] api: add redis to healthchecks --- Notesnook.API/Notesnook.API.csproj | 1 + Notesnook.API/Startup.cs | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Notesnook.API/Notesnook.API.csproj b/Notesnook.API/Notesnook.API.csproj index e2dd17b..946305e 100644 --- a/Notesnook.API/Notesnook.API.csproj +++ b/Notesnook.API/Notesnook.API.csproj @@ -9,6 +9,7 @@ + diff --git a/Notesnook.API/Startup.cs b/Notesnook.API/Startup.cs index f7fbd48..f294b42 100644 --- a/Notesnook.API/Startup.cs +++ b/Notesnook.API/Startup.cs @@ -25,6 +25,7 @@ using System.Text; using System.Text.Encodings.Web; using System.Threading.Tasks; using Amazon.Runtime; +using StackExchange.Redis; using IdentityModel.AspNetCore.OAuth2Introspection; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.JwtBearer; @@ -219,7 +220,20 @@ namespace Notesnook.API }).AddMessagePackProtocol().AddJsonProtocol(); if (!string.IsNullOrEmpty(Constants.SIGNALR_REDIS_CONNECTION_STRING)) - signalR.AddStackExchangeRedis(Constants.SIGNALR_REDIS_CONNECTION_STRING); + { + services.AddHealthChecks() + .AddRedis(Constants.SIGNALR_REDIS_CONNECTION_STRING, tags: ["ready"]); + signalR.AddStackExchangeRedis(options => + { + options.Configuration = ConfigurationOptions.Parse(Constants.SIGNALR_REDIS_CONNECTION_STRING); + options.Configuration.AbortOnConnectFail = false; + options.Configuration.ConnectRetry = 5; + options.Configuration.ReconnectRetryPolicy = new ExponentialRetry(5000, 30000); + options.Configuration.KeepAlive = 60; + options.Configuration.ConnectTimeout = 5000; + options.Configuration.SyncTimeout = 5000; + }); + } services.AddResponseCompression(options => {