-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #280 from ONLYOFFICE/feature/healthcheck
added health checks
- Loading branch information
Showing
33 changed files
with
461 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
PUSHD %~dp0.. | ||
dotnet build ASC.Web.sln /fl1 /flp1:LogFile=build/ASC.Web.log;Verbosity=Normal | ||
|
||
echo "ASC.UrlShortener" | ||
call build\scripts\urlshortener.sh | ||
@echo off | ||
|
||
echo "ASC.Thumbnails" | ||
call build\scripts\thumbnails.sh | ||
|
||
echo "ASC.Socket.IO" | ||
call build\scripts\socket.sh | ||
if %errorlevel% == 0 ( | ||
for /R "build\scripts\" %%f in (*.sh) do ( | ||
echo "%%~nxf" | ||
call build\scripts\%%~nxf | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
echo "RUN ASC.Web.HealthChecks.UI" | ||
call dotnet run --project ..\..\web\ASC.Web.HealthChecks.UI\ASC.Web.HealthChecks.UI.csproj --no-build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
yarn install --cwd common/ASC.SsoAuth --frozen-lockfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using ASC.Api.Core.Core; | ||
|
||
using HealthChecks.UI.Client; | ||
|
||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.AspNetCore.Diagnostics.HealthChecks; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace ASC.Api.Core | ||
{ | ||
public class BaseWorkerStartup | ||
{ | ||
public IConfiguration Configuration { get; } | ||
|
||
public BaseWorkerStartup(IConfiguration configuration) | ||
{ | ||
Configuration = configuration; | ||
} | ||
|
||
public virtual void ConfigureServices(IServiceCollection services) | ||
{ | ||
services.AddCustomHealthCheck(Configuration); | ||
} | ||
|
||
public virtual void Configure(IApplicationBuilder app) | ||
{ | ||
app.UseRouting(); | ||
|
||
app.UseEndpoints(endpoints => | ||
{ | ||
endpoints.MapHealthChecks("/health", new HealthCheckOptions() | ||
{ | ||
Predicate = _ => true, | ||
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse | ||
}); | ||
endpoints.MapHealthChecks("/liveness", new HealthCheckOptions | ||
{ | ||
Predicate = r => r.Name.Contains("self") | ||
}); | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
using System; | ||
using System.Linq; | ||
|
||
using ASC.Common.Caching; | ||
using ASC.Common.Utils; | ||
|
||
using Confluent.Kafka; | ||
|
||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Diagnostics.HealthChecks; | ||
|
||
namespace ASC.Api.Core.Core | ||
{ | ||
public static class CustomHealthCheck | ||
{ | ||
public static IServiceCollection AddCustomHealthCheck(this IServiceCollection services, IConfiguration configuration) | ||
{ | ||
var hcBuilder = services.AddHealthChecks(); | ||
|
||
hcBuilder.AddCheck("self", () => HealthCheckResult.Healthy()); | ||
|
||
var configurationExtension = new ConfigurationExtension(configuration); | ||
|
||
var connectionString = configurationExtension.GetConnectionStrings("default"); | ||
|
||
if (String.Compare(connectionString.ProviderName, "MySql.Data.MySqlClient") == 0) | ||
{ | ||
hcBuilder.AddMySql(connectionString.ConnectionString, | ||
name: "mysqldb", | ||
tags: new string[] { "mysqldb" } | ||
); | ||
} | ||
|
||
if (String.Compare(connectionString.ProviderName, "Npgsql") == 0) | ||
{ | ||
hcBuilder.AddNpgSql(connectionString.ConnectionString, | ||
name: "postgredb", | ||
tags: new string[] { "postgredb" } | ||
); | ||
} | ||
|
||
var kafkaSettings = configurationExtension.GetSetting<KafkaSettings>("kafka"); | ||
|
||
if (kafkaSettings != null && !string.IsNullOrEmpty(kafkaSettings.BootstrapServers)) | ||
{ | ||
var clientConfig = new ClientConfig { BootstrapServers = kafkaSettings.BootstrapServers }; | ||
|
||
hcBuilder.AddKafka(new ProducerConfig(clientConfig), | ||
name: "kafka", | ||
tags: new string[] { "kafka" }); | ||
|
||
} | ||
|
||
|
||
var elasticSettings = configuration.GetSection("elastic"); | ||
|
||
if (elasticSettings != null && elasticSettings.GetChildren().Any()) | ||
{ | ||
var host = elasticSettings.GetSection("Host").Value ?? "localhost"; | ||
var scheme = elasticSettings.GetSection("Scheme").Value ?? "http"; | ||
var port = elasticSettings.GetSection("Port").Value ?? "9200"; | ||
var elasticSearchUri = $"{scheme}://{host}:{port}"; | ||
|
||
if (Uri.IsWellFormedUriString(elasticSearchUri, UriKind.Absolute)) | ||
{ | ||
hcBuilder.AddElasticsearch(elasticSearchUri, | ||
name: "elasticsearch", | ||
tags: new string[] { "elasticsearch" }); | ||
} | ||
} | ||
|
||
return services; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.