Http status codes for health probes

Does servicestack have any return health status codes configured ?

Using micro-services in kubernetes requires health probes when using the status of the underlying app in determining whether traffic should be served or not.

So using Microsoft.Extensions.Diagnostics.HealthChecks I would normally just do the following in my api.

return HealthCheckResult.Healthy(“Healthy”); /this return status code 200

return HealthCheckResult.Unhealthy(“Not Healthy”); //this return I think status code 503

Kubernetes sees Status code 200-400 as healthy
and anything other than that as unhealthy.

I don’t see anything like this in SS , currently I’m using HttpError.Forbidden to return a unhealthy state but it would be nice to see something like HttpError.Unhealthy or something equivalent.

There’s wasn’t a concrete method wrapper (I’ve just added some in this commit), but you can return or throw a HttpError directly with:

return new HttpError(HttpStatusCode.ServiceUnavailable, "Not Healthy");

thanks @mythz , much appreciated. :smile:

1 Like