File tree Expand file tree Collapse file tree 2 files changed +41
-5
lines changed
Expand file tree Collapse file tree 2 files changed +41
-5
lines changed Original file line number Diff line number Diff line change 1+ using Microsoft . Extensions . Diagnostics . HealthChecks ;
2+
3+ [ assembly: HostingStartup ( typeof ( MyApp . HealthChecks ) ) ]
4+
5+ namespace MyApp ;
6+
7+ public class HealthChecks : IHostingStartup
8+ {
9+ public class HealthCheck : IHealthCheck
10+ {
11+ public async Task < HealthCheckResult > CheckHealthAsync ( HealthCheckContext context , CancellationToken token = default )
12+ {
13+ // Perform health check logic here
14+ return HealthCheckResult . Healthy ( ) ;
15+ }
16+ }
17+
18+ public void Configure ( IWebHostBuilder builder )
19+ {
20+ builder . ConfigureServices ( services =>
21+ {
22+ services . AddHealthChecks ( )
23+ . AddCheck < HealthCheck > ( "HealthCheck" ) ;
24+
25+ services . AddTransient < IStartupFilter , StartupFilter > ( ) ;
26+ } ) ;
27+ }
28+
29+ public class StartupFilter : IStartupFilter
30+ {
31+ public Action < IApplicationBuilder > Configure ( Action < IApplicationBuilder > next )
32+ => app => {
33+ app . UseHealthChecks ( "/up" ) ;
34+ next ( app ) ;
35+ } ;
36+ }
37+ }
Original file line number Diff line number Diff line change @@ -4,6 +4,10 @@ service: my-app
44# Name of the container image.
55image : my-user/myapp
66
7+ # Required for use of ASP.NET Core with Kamal-Proxy.
8+ env :
9+ ASPNETCORE_FORWARDEDHEADERS_ENABLED : true
10+
711# Deploy to these servers.
812servers :
913 # IP address of server, optionally use env variable.
@@ -21,11 +25,6 @@ proxy:
2125 # kamal-proxy connects to your container over port 80, use `app_port` to specify a different port.
2226 app_port : 8080
2327
24- healthcheck :
25- interval : 3
26- path : /metadata
27- timeout : 3
28-
2928# Credentials for your image host.
3029registry :
3130 # Specify the registry server, if you're not using Docker Hub
You can’t perform that action at this time.
0 commit comments