From 26157076d686a5dd3f8157ec2b2d1ae9d9e9eedf Mon Sep 17 00:00:00 2001 From: Janis Date: Wed, 7 Jan 2026 15:04:46 +0100 Subject: [PATCH] feat: Add logging to Gateway for pod synchronization and startup events --- .../app/controllers/HealthController.scala | 30 +++++++++++++++++++ knockoutwhistweb/app/logic/Gateway.scala | 6 ++-- knockoutwhistweb/conf/routes | 5 +++- 3 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 knockoutwhistweb/app/controllers/HealthController.scala diff --git a/knockoutwhistweb/app/controllers/HealthController.scala b/knockoutwhistweb/app/controllers/HealthController.scala new file mode 100644 index 0000000..4e89b1e --- /dev/null +++ b/knockoutwhistweb/app/controllers/HealthController.scala @@ -0,0 +1,30 @@ +package controllers + +import auth.{AuthAction, AuthenticatedRequest} +import dto.subDTO.UserDTO +import logic.user.{SessionManager, UserManager} +import model.users.User +import play.api.* +import play.api.libs.json.Json +import play.api.mvc.* +import play.api.mvc.Cookie.SameSite.{Lax, None, Strict} + +import javax.inject.* + + +/** + * This controller creates an `Action` to handle HTTP requests to the + * application's home page. + */ +@Singleton +class HealthController @Inject()( + val controllerComponents: ControllerComponents, + ) extends BaseController { + + def simple(): Action[AnyContent] = { + Action { implicit request => + Ok("OK") + } + } + +} \ No newline at end of file diff --git a/knockoutwhistweb/app/logic/Gateway.scala b/knockoutwhistweb/app/logic/Gateway.scala index 4d1a005..761617c 100644 --- a/knockoutwhistweb/app/logic/Gateway.scala +++ b/knockoutwhistweb/app/logic/Gateway.scala @@ -22,12 +22,14 @@ class Gateway @Inject()( val redis: RedisManager = { val config: Config = Config() - config.useSingleServer.setAddress("valkey://" + sys.env.getOrElse("VALKEY_HOST", "localhost") + ":" + sys.env.getOrElse("VALKEY_PORT", "6379")) + val url = "valkey://" + sys.env.getOrElse("VALKEY_HOST", "localhost") + ":" + sys.env.getOrElse("VALKEY_PORT", "6379") + logger.info(s"Connecting to Valkey at $url") + config.useSingleServer.setAddress(url) RedisManager(config) } redis.continuousSyncPod(() => { - logger.info("Syncing pod with Redis") + logger.info("Syncing pod with Valkey") createPod() }) diff --git a/knockoutwhistweb/conf/routes b/knockoutwhistweb/conf/routes index 3ef42af..dc89fca 100644 --- a/knockoutwhistweb/conf/routes +++ b/knockoutwhistweb/conf/routes @@ -30,4 +30,7 @@ GET /websocket controllers.WebsocketController.socket() # Status GET /status controllers.StatusController.requestStatus() -GET /status/:gameId controllers.StatusController.game(gameId: String) \ No newline at end of file +GET /status/:gameId controllers.StatusController.game(gameId: String) + +# Health +GET /health/simple controllers.HealthController.simple() \ No newline at end of file