From e8313f461ba4d24418f2e3080081f6268324805b Mon Sep 17 00:00:00 2001 From: Clivern Date: Sat, 21 Mar 2020 23:04:32 +0100 Subject: [PATCH] update & bump --- Dockerfile | 5 ++++- README.md | 6 +++--- deployment/k8s/deployment.yaml | 2 +- toad.go | 22 ++++++++++++++++++++++ 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 024c945..bfe9aa6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM golang:1.14.1 -ARG TOAD_VERSION=0.1.5 +ARG TOAD_VERSION=0.1.6 ENV GO111MODULE=on @@ -20,4 +20,7 @@ RUN ./toad --get=release EXPOSE 8080 +HEALTHCHECK --interval=5s --timeout=2s --retries=5 --start-period=2s \ + CMD ./toad --get health + CMD ["./toad", "--port", "8080"] \ No newline at end of file diff --git a/README.md b/README.md index b345dbd..2fe0f6e 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@

- Toad Logo + Toad Logo

Toad

Containerized Application for Testing Purposes

- - + +

diff --git a/deployment/k8s/deployment.yaml b/deployment/k8s/deployment.yaml index 3eadb0d..e2e27db 100644 --- a/deployment/k8s/deployment.yaml +++ b/deployment/k8s/deployment.yaml @@ -17,6 +17,6 @@ spec: spec: containers: - name: toad - image: clivern/toad:release-0.1.5 + image: clivern/toad:release-0.1.6 ports: - containerPort: 8080 \ No newline at end of file diff --git a/toad.go b/toad.go index 793c045..e55a6a9 100644 --- a/toad.go +++ b/toad.go @@ -37,6 +37,11 @@ func main() { flag.StringVar(&get, "get", "", "get") flag.Parse() + if get == "health" { + fmt.Println("i am ok") + return + } + if get == "release" { fmt.Println( fmt.Sprintf( @@ -59,6 +64,23 @@ func main() { c.String(http.StatusNoContent, "") }) + r.GET("/_health", func(c *gin.Context) { + u := uuid.Must(uuid.NewV4(), nil) + host, _ := os.Hostname() + + log.WithFields(log.Fields{ + "time": time.Now().Format("Mon Jan 2 15:04:05 2006"), + "host": host, + "uri": c.Request.URL.Path, + "method": c.Request.Method, + "correlationId": u.String(), + }).Info("Incoming Request") + + c.JSON(http.StatusOK, gin.H{ + "status": "ok", + }) + }) + r.GET("/", func(c *gin.Context) { u := uuid.Must(uuid.NewV4(), nil) host, _ := os.Hostname()