Skip to content

Commit 105e457

Browse files
authored
FUND-1570 NRC- and DRC-Listeners add health-check (#86)
* added health-endpoints to nrc- and drc-listeners * dispose CancellationToken * code review changes * code review changes ii * Haproxy config file fixed and README updated * README fiel corrected * .ENV file corrected * code review changes iii
1 parent 1bbea33 commit 105e457

File tree

13 files changed

+83
-16
lines changed

13 files changed

+83
-16
lines changed

getting-started/docker-compose/.env

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ KEYCLOAK_ADMIN_PASSWORD=admin
4040
HAPROXY_CONFIG_PATH=../../localdev/haproxy/haproxy-localstack.cfg
4141
ONEGROUND_CERTIFICATES_PATH=./oneground-certificates
4242

43+
# Notificatie-listener
44+
NRC_LISTENER_PORT=5098
45+
NRC_LISTENER_HOST=notificatielistener.oneground.local
46+
47+
# Document-listener
48+
DRC_LISTENER_PORT=5099
49+
DRC_LISTENER_HOST=documentlistener.oneground.local
50+
4351
# ZGW ports
4452
AC_PORT=5009
4553
AC_HOST=localhost

getting-started/docker-compose/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ To ensure all services can communicate with each other and are accessible in you
149149
127.0.0.1 documenten.oneground.local
150150
127.0.0.1 autorisaties.oneground.local
151151
127.0.0.1 referentielijsten.oneground.local
152+
127.0.0.1 notificatielistener.oneground.local
153+
127.0.0.1 documentlistener.oneground.local
152154
127.0.0.1 haproxy.oneground.local
153155
```
154156

@@ -283,7 +285,7 @@ docker compose down
283285

284286
Here is a reference list of all the services and tools running in this Docker setup.
285287

286-
### ZGW API Services
288+
### ZGW API Services/Listeners
287289

288290
| Service | Port | Swagger UI | Health Check |
289291
| :--- | :--- | :--- | :--- |
@@ -294,6 +296,8 @@ Here is a reference list of all the services and tools running in this Docker se
294296
| **Notificaties API** | 5015 | [https://notificaties.oneground.local/swagger](https://notificaties.oneground.local/swagger) | [https://notificaties.oneground.local/health](https://notificaties.oneground.local/health) |
295297
| **Referentielijsten API** | 5018 | [https://referentielijsten.oneground.local/swagger](https://referentielijsten.oneground.local/swagger) | [https://referentielijsten.oneground.local/health](https://referentielijsten.oneground.local/health) |
296298
| **Zaken API** | 5005 | [https://zaken.oneground.local/swagger](https://zaken.oneground.local/swagger) | [https://zaken.oneground.local/health](https://zaken.oneground.local/health) |
299+
| **Notificatielistener (message dispatcher)** | 5098 | [https://notificatielistener.oneground.local/health](https://notificatielistener.oneground.local/health) |
300+
| **Documentlistener (message dispatcher)** | 5099 | [https://documentlistener.oneground.local/health](https://documentlistener.oneground.local/health) |
297301

298302
### Hosted Tools
299303

localdev/.env

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ KEYCLOAK_ADMIN_PASSWORD=admin
4545
HAPROXY_CONFIG_PATH=./haproxy/haproxy-localstack.cfg
4646
ONEGROUND_CERTIFICATES_PATH=./oneground-certificates
4747

48+
# Notificatie-listener
49+
NRC_LISTENER_PORT=5098
50+
NRC_LISTENER_HOST=notificatielistener.oneground.local
51+
52+
# Document-listener
53+
DRC_LISTENER_PORT=5099
54+
DRC_LISTENER_HOST=documentlistener.oneground.local
55+
4856
# ZGW ports
4957
AC_PORT=5009
5058
AC_HOST=localhost

localdev/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ To ensure all services can communicate with each other and are accessible in you
152152
127.0.0.1 documenten.oneground.local
153153
127.0.0.1 autorisaties.oneground.local
154154
127.0.0.1 referentielijsten.oneground.local
155+
127.0.0.1 notificatielistener.oneground.local
156+
127.0.0.1 documentlistener.oneground.local
155157
127.0.0.1 haproxy.oneground.local
156158
```
157159
@@ -259,7 +261,7 @@ docker compose down
259261
260262
Here is a reference list of all the services and tools running in this Docker setup.
261263
262-
### ZGW API Services
264+
### ZGW API Services/listeners
263265
264266
| Service | Port | Swagger UI | Health Check |
265267
| :--- | :--- | :--- | :--- |
@@ -270,6 +272,8 @@ Here is a reference list of all the services and tools running in this Docker se
270272
| **Notificaties API** | 5015 | [https://notificaties.oneground.local/swagger](https://notificaties.oneground.local/swagger) | [https://notificaties.oneground.local/health](https://notificaties.oneground.local/health) |
271273
| **Referentielijsten API** | 5018 | [https://referentielijsten.oneground.local/swagger](https://referentielijsten.oneground.local/swagger) | [https://referentielijsten.oneground.local/health](https://referentielijsten.oneground.local/health) |
272274
| **Zaken API** | 5005 | [https://zaken.oneground.local/swagger](https://zaken.oneground.local/swagger) | [https://zaken.oneground.local/health](https://zaken.oneground.local/health) |
275+
| **Notificatielistener (message dispatcher)** | 5098 | [https://notificatielistener.oneground.local/health](https://notificatielistener.oneground.local/health) |
276+
| **Documentlistener (message dispatcher)** | 5099 | [https://documentlistener.oneground.local/health](https://documentlistener.oneground.local/health) |
273277
274278
### Hosted Tools
275279

localdev/haproxy/haproxy-localstack.cfg

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ frontend frontend
9494
acl referentielijsten hdr(host) referentielijsten.oneground.local
9595
use_backend referentielijsten if referentielijsten
9696

97+
acl notificatielistener hdr(host) notificatielistener.oneground.local
98+
use_backend notificatielistener if notificatielistener
99+
100+
acl documentlistener hdr(host) documentlistener.oneground.local
101+
use_backend documentlistener if documentlistener
102+
97103
#---------------------------------------------------------------------
98104
# Backend settings
99105
#---------------------------------------------------------------------
@@ -136,3 +142,13 @@ backend referentielijsten
136142
balance leastconn
137143
option httpchk GET /health
138144
server docker-host host.docker.internal:5018 check
145+
146+
backend notificatielistener
147+
balance leastconn
148+
option httpchk GET /health
149+
server docker-host host.docker.internal:5098 check
150+
151+
backend documentlistener
152+
balance leastconn
153+
option httpchk GET /health
154+
server docker-host host.docker.internal:5099 check

src/OneGround.ZGW.Documenten.Messaging.Listener/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ WORKDIR /app
2121

2222
COPY --from=build /app/publish .
2323

24+
RUN apt-get update -yq \
25+
&& apt-get install curl -yq \
26+
&& rm -rf /var/lib/apt/lists/*
27+
2428
USER $APP_UID
2529

30+
HEALTHCHECK --interval=60s --timeout=5s --retries=3 CMD curl -k -f http://localhost:5000/health || exit 1
31+
2632
ENTRYPOINT ["./OneGround.ZGW.Documenten.Messaging.Listener"]
Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
1-
using Microsoft.Extensions.Hosting;
1+
using Microsoft.AspNetCore.Builder;
2+
using Microsoft.Extensions.DependencyInjection;
23
using OneGround.ZGW.Common.Configuration;
34
using OneGround.ZGW.Common.Constants;
45
using OneGround.ZGW.Common.Extensions;
56
using OneGround.ZGW.Common.Web.Extensions.ServiceCollection;
67
using OneGround.ZGW.Documenten.Messaging;
78

8-
var builder = Host.CreateApplicationBuilder();
9+
var builder = WebApplication.CreateBuilder(args);
10+
911
builder.ConfigureHostDefaults(ServiceRoleName.DRC_LISTENER);
1012

13+
builder.Services.AddHealthChecks();
14+
1115
var serviceConfiguration = new ServiceConfiguration(builder.Configuration);
1216
serviceConfiguration.ConfigureServices(builder.Services);
1317
builder.Services.AddZGWSecretManager(builder.Configuration);
1418
builder.Services.RegisterZgwTokenClient(builder.Configuration, builder.Environment);
1519

1620
var app = builder.Build();
1721

18-
app.Run();
22+
app.MapHealthChecks("/health");
23+
24+
await app.RunAsync();
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
{
2+
"$schema": "https://json.schemastore.org/launchsettings.json",
23
"profiles": {
34
"ZGW.Documenten.Messaging.Listener": {
45
"commandName": "Project",
56
"environmentVariables": {
6-
"DOTNET_ENVIRONMENT": "Local"
7-
}
7+
"ASPNETCORE_ENVIRONMENT": "Local"
8+
},
9+
"applicationUrl": "http://*:5099"
810
},
911
"Docker": {
1012
"commandName": "Docker"
1113
}
1214
}
13-
}
15+
}

src/OneGround.ZGW.Documenten.Messaging.Listener/ZGW.Documenten.Messaging.Listener.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk.Worker">
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
22
<PropertyGroup>
33
<TargetFramework>net8.0</TargetFramework>
44
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>

src/OneGround.ZGW.Notificaties.Messaging.Listener/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ WORKDIR /app
2121

2222
COPY --from=build /app/publish .
2323

24+
RUN apt-get update -yq \
25+
&& apt-get install curl -yq \
26+
&& rm -rf /var/lib/apt/lists/*
27+
2428
USER $APP_UID
2529

30+
HEALTHCHECK --interval=60s --timeout=5s --retries=3 CMD curl -k -f http://localhost:5000/health || exit 1
31+
2632
ENTRYPOINT ["./OneGround.ZGW.Notificaties.Messaging.Listener"]

0 commit comments

Comments
 (0)