Skip to content

Commit

Permalink
feat: add Kamal deployment configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Layoric committed Nov 26, 2024
1 parent 3cf8bd7 commit 4d162d2
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 5 deletions.
37 changes: 37 additions & 0 deletions MyApp/Configure.HealthChecks.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using Microsoft.Extensions.Diagnostics.HealthChecks;

[assembly: HostingStartup(typeof(MyApp.HealthChecks))]

namespace MyApp;

public class HealthChecks : IHostingStartup
{
public class HealthCheck : IHealthCheck
{
public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken token = default)

Check warning on line 11 in MyApp/Configure.HealthChecks.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
// Perform health check logic here
return HealthCheckResult.Healthy();
}
}

public void Configure(IWebHostBuilder builder)
{
builder.ConfigureServices(services =>
{
services.AddHealthChecks()
.AddCheck<HealthCheck>("HealthCheck");
services.AddTransient<IStartupFilter, StartupFilter>();
});
}

public class StartupFilter : IStartupFilter
{
public Action<IApplicationBuilder> Configure(Action<IApplicationBuilder> next)
=> app => {
app.UseHealthChecks("/up");
next(app);
};
}
}
5 changes: 0 additions & 5 deletions config/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ proxy:
# kamal-proxy connects to your container over port 80, use `app_port` to specify a different port.
app_port: 8080

healthcheck:
interval: 3
path: /metadata
timeout: 3

# Credentials for your image host.
registry:
# Specify the registry server, if you're not using Docker Hub
Expand Down

0 comments on commit 4d162d2

Please sign in to comment.