Add a healthcheck endpoint (#468)

The purpose of this endpoint is to respond only with http code 200, to
be used by services such as Docker to check if the server is still
running.
This commit is contained in:
Michael Green
2024-12-19 14:18:36 +11:00
committed by GitHub
parent 81b58e9b9f
commit 98a09c32f8
2 changed files with 22 additions and 0 deletions

View File

@@ -32,5 +32,8 @@ ENV INDOCKER=1
WORKDIR /App
COPY --from=build-env /App/out .
# Configure healthcheck
HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 CMD curl --fail http://localhost:80/healthCheck || exit 1
# start gaseous-server
ENTRYPOINT ["dotnet", "gaseous-server.dll"]

View File

@@ -0,0 +1,19 @@
using Microsoft.AspNetCore.Mvc;
using Asp.Versioning;
namespace gaseous_server.Controllers.v1_1
{
[Route("api/v{version:apiVersion}/[controller]")]
[ApiVersion("1.1")]
[ApiController]
public class HealthCheckController : ControllerBase
{
[MapToApiVersion("1.1")]
[HttpGet]
[ProducesResponseType(StatusCodes.Status200OK)]
public ActionResult Healthcheck()
{
return Ok();
}
}
}