From: Olliver Schinagl Date: Sat, 10 Jun 2023 15:16:06 +0000 (+0200) Subject: Add simple 'ping' endpoint for healthchecks X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=1705297c27d76848a87cff34dd6bfe7d9d74c87a;p=thirdparty%2Ftvheadend.git Add simple 'ping' endpoint for healthchecks To determine if the server is online, we want to be able to 'ping' it with as little configuration and access possibilities as possible. The only available option for this today, is anonymous access. Let us thus add a new endpoint, that replies with 'PONG' when queried. This will need anonymous access enabled, but can be restricted to: a) localhost b) without any access permissions Signed-off-by: Olliver Schinagl --- diff --git a/src/webui/simpleui.c b/src/webui/simpleui.c index 3443029cf..16b808f75 100644 --- a/src/webui/simpleui.c +++ b/src/webui/simpleui.c @@ -17,6 +17,7 @@ */ #include "tvheadend.h" +#include "htsbuf.h" #include "http.h" #include "webui.h" #include "access.h" @@ -398,6 +399,19 @@ page_einfo(http_connection_t *hc, const char *remain, void *opaque) return 0; } +/** + * Simple ping 'page', for healthcheck purposes + */ +static int page_ping(http_connection_t *hc, const char *remain, void *opaque) +{ + htsbuf_queue_t *hq = &hc->hc_reply; + + htsbuf_qprintf(hq, "PONG\n"); + http_output_content(hc, "text/plain"); + + return 0; +} + /** * PVR info, deliver info about the given PVR entry */ @@ -620,6 +634,7 @@ simpleui_start(void) { http_path_add("/simple.html", NULL, page_simple, ACCESS_SIMPLE); http_path_add("/eventinfo", NULL, page_einfo, ACCESS_SIMPLE); + http_path_add("/ping", NULL, page_ping, ACCESS_ANONYMOUS); http_path_add("/pvrinfo", NULL, page_pvrinfo, ACCESS_SIMPLE); http_path_add("/status.xml", NULL, page_status, ACCESS_SIMPLE); http_path_add("/epgsave", NULL, page_epgsave, ACCESS_SIMPLE);