From 32c2f20da9a405bcfb3d2566e031f2187a876984 Mon Sep 17 00:00:00 2001 From: mohamedasifs123 Date: Thu, 19 Dec 2024 15:38:10 +0530 Subject: [PATCH] feat: adding health checks Signed-off-by: mohamedasifs123 --- config/demo-trace/main.go | 15 ++++++++++++++- docker-compose.yml | 13 ++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/config/demo-trace/main.go b/config/demo-trace/main.go index 9074346..3e3c7fd 100644 --- a/config/demo-trace/main.go +++ b/config/demo-trace/main.go @@ -166,5 +166,18 @@ func main() { } span.End() time.Sleep(5 * time.Second) - } + // Health check endpoint + http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusOK) + fmt.Fprintln(w, "OK") + }) + + // Application logic + http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprintln(w, "Hello, World!") + }) + + // Start server + http.ListenAndServe(":57400", nil) + } } diff --git a/docker-compose.yml b/docker-compose.yml index aa937bf..bb16074 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -159,6 +159,12 @@ services: - spdk networks: - opi + healthcheck: + test: wget --no-verbose --tries=1 --spider http://localhost:57400/health + interval: 10s + timeout: 10s + retries: 5 + jaeger-all-in-one: image: jaegertracing/all-in-one:latest @@ -169,7 +175,12 @@ services: - "14250" networks: - opi - + healthcheck: + test: wget --no-verbose --tries=1 --spider http://localhost:16686 || exit 1 + interval: 6s + timeout: 10s + retries: 5 + volumes: influxdb-storage: