From 30444b4a72a030419ff8d1efe969cb19750727d5 Mon Sep 17 00:00:00 2001 From: Jibbajabbafic Date: Fri, 2 Feb 2024 00:21:55 +0000 Subject: [PATCH] fix(docker): fix healthcheck --- Dockerfile | 2 +- src/main.rs | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 20b2a9d..6ebf899 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,7 +22,7 @@ WORKDIR /app RUN apt update && apt install -y curl HEALTHCHECK --interval=1m --timeout=10s --retries=3 --start-period=1m \ - CMD curl --fail localhost:3000/api/list/servers || exit 1 + CMD curl --fail localhost:3000/api/list/healthcheck || exit 1 COPY --from=builder /app/target/release/game_server_list /usr/local/bin ENTRYPOINT ["/usr/local/bin/game_server_list"] diff --git a/src/main.rs b/src/main.rs index 90e8b2f..1b7d311 100644 --- a/src/main.rs +++ b/src/main.rs @@ -86,6 +86,7 @@ async fn main() { // build our application with some routes let app = Router::new() + .route("/api/list/healthcheck", get(healthcheck)) .route("/api/list/servers", get(get_servers)) // websocket route .route("/api/list/ws", get(websocket_handler)) @@ -119,6 +120,11 @@ async fn main() { .unwrap(); } +// Added for Docker healthcheck to ensure server still responding +async fn healthcheck() -> &'static str { + "Success!" +} + #[instrument(skip(app_state))] async fn get_servers( pagination: Option>,