Skip to content

Commit b0cb530

Browse files
committed
Add Host Offline logs to all admin requests
Signed-off-by: Ankit Kumar <[email protected]>
1 parent 02cb7b3 commit b0cb530

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/WebJobs.Script.WebHost/Controllers/HostController.cs

+10-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
using Microsoft.Extensions.Logging;
2525
using Microsoft.Extensions.Options;
2626
using Newtonsoft.Json;
27+
using Newtonsoft.Json.Linq;
2728
using HttpHandler = Microsoft.Azure.WebJobs.IAsyncConverter<System.Net.Http.HttpRequestMessage, System.Net.Http.HttpResponseMessage>;
2829

2930
namespace Microsoft.Azure.WebJobs.Script.WebHost.Controllers
@@ -93,8 +94,16 @@ public async Task<IActionResult> GetHostStatus([FromServices] IScriptHostManager
9394
[HttpPost]
9495
[Route("admin/host/ping")]
9596
[ResponseCache(NoStore = true, Location = ResponseCacheLocation.None)]
96-
public IActionResult Ping()
97+
public IActionResult Ping([FromServices] IScriptHostManager scriptHostManager)
9798
{
99+
var pingStatus = new JObject
100+
{
101+
{ "hostState", scriptHostManager.State.ToString() }
102+
};
103+
104+
string message = $"Ping Status: {pingStatus.ToString()}";
105+
_logger.Log(LogLevel.Debug, new EventId(0, "PingStatus"), message);
106+
98107
return Ok();
99108
}
100109

0 commit comments

Comments
 (0)