You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#ROBOMERGE-AUTHOR: ben.marsh #ROBOMERGE-SOURCE: CL 17926237 in //UE5/Main/... #ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v885-17909292) [CL 17926263 by ben marsh in ue5-release-engine-test branch]
68 lines
2.0 KiB
C#
68 lines
2.0 KiB
C#
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
using HordeServer.Services;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace HordeServer.Controllers
|
|
{
|
|
/// <summary>
|
|
/// Controller for app lifetime related routes
|
|
/// </summary>
|
|
[ApiController]
|
|
[Route("[controller]")]
|
|
public class LifetimeController : ControllerBase
|
|
{
|
|
/// <summary>
|
|
/// Singleton instance of the lifetime service
|
|
/// </summary>
|
|
LifetimeService LifetimeService;
|
|
|
|
/// <summary>
|
|
/// Constructor
|
|
/// </summary>
|
|
/// <param name="LifetimeService">The lifetime service singleton</param>
|
|
public LifetimeController(LifetimeService LifetimeService)
|
|
{
|
|
this.LifetimeService = LifetimeService;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Readiness check for server
|
|
///
|
|
/// When a SIGTERM has been received, the server is shutting down.
|
|
/// To communicate the server is stopping to load balancers/orchestrators, this route will return either 503 or 200.
|
|
/// The server will continue to serve requests, but it's assumed the load balancer has reacted and stopped sending
|
|
/// traffic by the time the server process exits.
|
|
/// </summary>
|
|
/// <returns>Status code 503 is server is stopping, else 200 OK</returns>
|
|
[HttpGet]
|
|
[Route("/health/ready")]
|
|
public Task<ActionResult> ServerReadiness()
|
|
{
|
|
int StatusCode = 200;
|
|
string Content = "ok";
|
|
|
|
if (LifetimeService.IsPreStopping)
|
|
{
|
|
StatusCode = 503; // Service Unavailable
|
|
Content = "stopping";
|
|
}
|
|
|
|
return Task.FromResult<ActionResult>(new ContentResult { ContentType = "text/plain", StatusCode = StatusCode, Content = Content });
|
|
}
|
|
|
|
/// <summary>
|
|
/// Liveness check for Kubernetes
|
|
/// If this return a non-successful HTTP response, Kubernetes will kill the pod and restart it
|
|
/// </summary>
|
|
/// <returns>Ok if app is not stopping and all databases can be reached</returns>
|
|
[HttpGet]
|
|
[Route("/health/live")]
|
|
public ActionResult K8sLivenessProbe()
|
|
{
|
|
return new ContentResult { ContentType = "text/plain", StatusCode = 200, Content = "ok" };
|
|
}
|
|
}
|
|
}
|