-
-
Notifications
You must be signed in to change notification settings - Fork 77
RE1-T102 Added healthcheck #279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| using System.Reflection; | ||
| using System.Threading.Tasks; | ||
| using Microsoft.AspNetCore.Authorization; | ||
| using Microsoft.AspNetCore.Mvc; | ||
| using Resgrid.Config; | ||
| using Resgrid.Web.Mcp.Infrastructure; | ||
| using Resgrid.Web.Mcp.Models; | ||
|
|
||
| namespace Resgrid.Web.Mcp.Controllers | ||
| { | ||
| /// <summary> | ||
| /// Health Check system to get information and health status of the MCP Server | ||
| /// </summary> | ||
| [AllowAnonymous] | ||
| [Route("health")] | ||
| public sealed class HealthController : Controller | ||
| { | ||
| private readonly McpToolRegistry _toolRegistry; | ||
| private readonly IResponseCache _responseCache; | ||
|
|
||
| public HealthController( | ||
| McpToolRegistry toolRegistry, | ||
| IResponseCache responseCache) | ||
| { | ||
| _toolRegistry = toolRegistry; | ||
| _responseCache = responseCache; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets the current health status of the MCP Server | ||
| /// </summary> | ||
| /// <returns>HealthResult object with the server health status</returns> | ||
| [HttpGet("current")] | ||
| public IActionResult GetCurrent() | ||
| { | ||
| var result = new HealthResult | ||
| { | ||
| ServerVersion = Assembly.GetEntryAssembly()?.GetName().Version?.ToString() ?? "Unknown", | ||
| ServerName = McpConfig.ServerName ?? "Resgrid MCP Server", | ||
| SiteId = "0", | ||
| ToolCount = _toolRegistry.GetToolCount(), | ||
| ServerRunning = true | ||
| }; | ||
|
|
||
| // Check cache connectivity | ||
| try | ||
| { | ||
| result.CacheOnline = _responseCache != null; | ||
| } | ||
| catch | ||
| { | ||
| result.CacheOnline = false; | ||
| } | ||
|
|
||
| // Check API connectivity | ||
| try | ||
| { | ||
| // Simple ping to the API to check connectivity | ||
| var apiBaseUrl = SystemBehaviorConfig.ResgridApiBaseUrl; | ||
| result.ApiOnline = !string.IsNullOrWhiteSpace(apiBaseUrl); | ||
| } | ||
| catch | ||
| { | ||
| result.ApiOnline = false; | ||
| } | ||
|
|
||
| return Json(result); | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -6,6 +6,7 @@ FROM mcr.microsoft.com/dotnet/aspnet:9.0.3-noble-amd64 AS base | |||||||||
| ARG BUILD_VERSION | ||||||||||
| WORKDIR /app | ||||||||||
| EXPOSE 80 | ||||||||||
| EXPOSE 5050 | ||||||||||
|
|
||||||||||
| FROM mcr.microsoft.com/dotnet/sdk:9.0.202-noble-amd64 AS build | ||||||||||
| ARG BUILD_VERSION | ||||||||||
|
|
@@ -43,4 +44,9 @@ RUN chmod +x wait | |||||||||
|
|
||||||||||
| WORKDIR /app | ||||||||||
| COPY --from=publish /app/publish . | ||||||||||
|
|
||||||||||
| # Health check configuration | ||||||||||
| HEALTHCHECK --interval=30s --timeout=10s --retries=3 --start-period=10s \ | ||||||||||
| CMD curl -f http://localhost:5050/health/current || exit 1 | ||||||||||
|
||||||||||
| HEALTHCHECK --interval=30s --timeout=10s --retries=3 --start-period=10s \ | |
| CMD curl -f http://localhost:5050/health/current || exit 1 | |
| HEALTHCHECK --interval=30s --timeout=10s --retries=3 --start-period=10s \ | |
| CMD wget --no-verbose --tries=1 --spider http://localhost:5050/health/current || exit 1 |
🤖 Prompt for AI Agents
In `@Web/Resgrid.Web.Mcp/Dockerfile` around lines 49 - 50, The HEALTHCHECK uses
curl which is not present in the dotnet/aspnet:9.0.3-noble-amd64 base image so
the probe will always fail; fix by either installing a HTTP client in the final
image (e.g., add apt-get update && apt-get install -y curl or wget in the final
stage before the HEALTHCHECK) or replace the HEALTHCHECK command with a
.NET-based health probe callable from the container; update the Dockerfile
HEALTHCHECK line accordingly and ensure the package install happens in the same
final stage that defines HEALTHCHECK (reference: the Dockerfile HEALTHCHECK and
the base image dotnet/aspnet:9.0.3-noble-amd64).
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| namespace Resgrid.Web.Mcp.Models | ||
| { | ||
| /// <summary> | ||
| /// Response for getting the health of the Resgrid MCP Server. | ||
| /// </summary> | ||
| public sealed class HealthResult | ||
| { | ||
| /// <summary> | ||
| /// Site\Location of this MCP Server | ||
| /// </summary> | ||
| public string SiteId { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// The Version of the MCP Server | ||
| /// </summary> | ||
| public string ServerVersion { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// The name of the MCP Server | ||
| /// </summary> | ||
| public string ServerName { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Number of registered tools | ||
| /// </summary> | ||
| public int ToolCount { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Can the MCP Server talk to the Resgrid API | ||
| /// </summary> | ||
| public bool ApiOnline { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Can the MCP Server talk to the cache | ||
| /// </summary> | ||
| public bool CacheOnline { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Is the MCP Server running | ||
| /// </summary> | ||
| public bool ServerRunning { get; set; } | ||
| } | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,4 +1,4 @@ | ||||||
| using System; | ||||||
| using System; | ||||||
|
||||||
| using System; | |
| using System; |
🤖 Prompt for AI Agents
In `@Web/Resgrid.Web.Mcp/Program.cs` at line 1, The file starts with stray BOM
characters before the initial directive; remove the leading BOM bytes so the
first token is "using System;" (i.e., ensure the top of Program.cs begins
exactly with the "using System;" line and no invisible characters precede it) to
resolve the build error.
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,4 +1,4 @@ | ||||||
| <Project Sdk="Microsoft.NET.Sdk"> | ||||||
| <Project Sdk="Microsoft.NET.Sdk.Web"> | ||||||
|
||||||
| <Project Sdk="Microsoft.NET.Sdk.Web"> | |
| <Project Sdk="Microsoft.NET.Sdk.Web"> |
🧰 Tools
🪛 GitHub Actions: .NET
[error] 1-1: MSB4025: The project file could not be loaded. Data at the root level is invalid. Line 1, position 1.
🤖 Prompt for AI Agents
In `@Web/Resgrid.Web.Mcp/Resgrid.Web.Mcp.csproj` at line 1, Remove the stray
double UTF-8 BOM at the start of the csproj and Program.cs so the files begin
exactly with "<Project" and "using" respectively; open Resgrid.Web.Mcp.csproj
and Program.cs, delete any invisible BOM characters at the very start, and save
both files as UTF-8 without BOM (or re-encode using your editor/CLI) so MSBuild
sees valid XML/CS source.
Uh oh!
There was an error while loading. Please reload this page.