Skip to content

Commit

Permalink
added health check to mock-service container
Browse files Browse the repository at this point in the history
  • Loading branch information
ShourieG committed Jul 17, 2024
1 parent 69fddcd commit 38628e5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
4 changes: 4 additions & 0 deletions packages/websocket/_dev/deploy/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ services:
- ./websocket-mock-service:/app
ports:
- "3000:3000"
healthcheck:
test: "wget --no-verbose --tries=1 --spider http://localhost:3000/health || exit 1"
interval: 10s
timeout: 5s
command: ["go", "run", "main.go"]
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,10 @@ func main() {
}

func handleWebSocket(w http.ResponseWriter, r *http.Request) {
upgrader := websocket.Upgrader{
CheckOrigin: func(r *http.Request) bool { return true },
}
conn, err := upgrader.Upgrade(w, r, nil)
if err != nil {
log.Println(err)

if r.URL.Path == "/health" {
return
}
defer conn.Close()

if r.URL.Path == "/testbasicauth" {
// Check if the 'Authorization' header is set for basic authentication
Expand All @@ -38,6 +33,16 @@ func handleWebSocket(w http.ResponseWriter, r *http.Request) {
}
}

upgrader := websocket.Upgrader{
CheckOrigin: func(r *http.Request) bool { return true },
}
conn, err := upgrader.Upgrade(w, r, nil)
if err != nil {
log.Println(err)
return
}
defer conn.Close()

var responseMessage []map[string]string

if r.URL.Path == "/testbasicauth" {
Expand Down

0 comments on commit 38628e5

Please sign in to comment.