Skip to content

Commit

Permalink
Merge pull request #82 from Raj-Adarsh/a8_cve_processor_v1
Browse files Browse the repository at this point in the history
fix: added graceful shutdown of envoy sidecar for job completion
  • Loading branch information
Raj-Adarsh authored Jul 31, 2024
2 parents 48eabe5 + 997feec commit 490401a
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions cmd/api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"context"
"fmt"
"net/http"
"os"
"os/signal"
"runtime"
Expand Down Expand Up @@ -92,6 +93,24 @@ func main() {
<-sigs
log.Print("Received shutdown signal, shutting down the application")
cancel()

// Define the endpoint for the Istio Envoy sidecar admin interface
istioEndpoint := "http://localhost:15020/quitquitquit"

// Create a POST request to shut down Envoy
req, err := http.NewRequest("POST", istioEndpoint, nil)
if err != nil {
log.Error().Err(err).Msg("Error creating request")
}

// Send the request using a new client
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
log.Error().Err(err).Msg("Error sending request to Envoy:")
}
defer resp.Body.Close()
log.Info().Msgf("Envoy shutdown response status: %s", resp.Status)
os.Exit(0)
}()

Expand Down

0 comments on commit 490401a

Please sign in to comment.