mirror of
https://github.com/bitwarden/server.git
synced 2025-07-04 17:42:49 -05:00
[SG-497] BEEEP - Health Checks API Project (#2237)
* health check services added * health check extension added * added get connection string * made changes to hrslth check method * Added database health check * added identity server health check * added identity server health check * Added logger publisher * latest changes * removed file * Added mail server check for dev * Added authorization to health check url path * commented * Added exception to switch * Removed exclude code coverage * Added health check for redis * Added todos * Added storage queue checks * Added checks for mail * Removed unused references and fixed linting issue * Lint issues * Moved healthchecks to sharedWeb project and exposed builder as a parameter to configure more health checks based on a project * Added health check to API project * dependencies updated * Removed ef core health check dependencies * Added checks to only add a health check when the connection string exists, moved health check from startup to extension class * Merged with master and fixed conflicts * Fixed lint issues * Added check for amazon ses * merged with master * fixed lint * Removed Amazon SES health check
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
using Bit.Core.IdentityServer;
|
||||
using Bit.Core.Settings;
|
||||
using Bit.SharedWeb.Health;
|
||||
using Microsoft.OpenApi.Models;
|
||||
|
||||
namespace Bit.Api.Utilities;
|
||||
@ -69,4 +70,48 @@ public static class ServiceCollectionExtensions
|
||||
config.IncludeXmlComments(coreFilePath);
|
||||
});
|
||||
}
|
||||
|
||||
public static void AddHealthChecks(this IServiceCollection services, GlobalSettings globalSettings)
|
||||
{
|
||||
services.AddHealthCheckServices(globalSettings, builder =>
|
||||
{
|
||||
var identityUri = new Uri(globalSettings.BaseServiceUri.Identity
|
||||
+ "/.well-known/openid-configuration");
|
||||
|
||||
builder.AddUrlGroup(identityUri, "identity");
|
||||
|
||||
if (!string.IsNullOrEmpty(globalSettings.SqlServer.ConnectionString))
|
||||
{
|
||||
builder.AddSqlServer(globalSettings.SqlServer.ConnectionString);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(globalSettings.Redis.ConnectionString))
|
||||
{
|
||||
builder.AddRedis(globalSettings.Redis.ConnectionString);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(globalSettings.Storage.ConnectionString))
|
||||
{
|
||||
builder.AddAzureQueueStorage(globalSettings.Storage.ConnectionString, name: "storage_queue")
|
||||
.AddAzureQueueStorage(globalSettings.Events.ConnectionString, name: "events_queue");
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(globalSettings.Notifications.ConnectionString))
|
||||
{
|
||||
builder.AddAzureQueueStorage(globalSettings.Notifications.ConnectionString,
|
||||
name: "notifications_queue");
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(globalSettings.ServiceBus.ConnectionString))
|
||||
{
|
||||
builder.AddAzureServiceBusTopic(_ => globalSettings.ServiceBus.ConnectionString,
|
||||
_ => globalSettings.ServiceBus.ApplicationCacheTopicName, name: "service_bus");
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(globalSettings.Mail.SendGridApiKey))
|
||||
{
|
||||
builder.AddSendGrid(globalSettings.Mail.SendGridApiKey);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user