Skip to content

Commit

Permalink
Merge pull request #352 from ca-risken/migrate-grpc_probe
Browse files Browse the repository at this point in the history
chore: delete http endpoint
  • Loading branch information
senk8 committed Jan 25, 2024
2 parents adc99d9 + a2a4bfb commit 2b27f76
Showing 1 changed file with 0 additions and 37 deletions.
37 changes: 0 additions & 37 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"net"
"net/http"
"os"
"os/signal"
"syscall"
Expand Down Expand Up @@ -130,23 +129,6 @@ func (s *Server) Run(ctx context.Context) error {
}
}()

mux := http.NewServeMux()
mux.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
if err := healthCheck(ctx, clientAddr); err != nil {
w.WriteHeader(http.StatusServiceUnavailable)
s.logger.Errorf(ctx, "health check is failed: %w", err)
} else {
fmt.Fprintln(w, "ok")
}
})

go func() {
if err := http.ListenAndServe(fmt.Sprintf("%s:3000", s.host), mux); err != http.ErrServerClosed {
s.logger.Errorf(ctx, "failed to start http server: %w", err)
errChan <- err
}
}()

ctx, stop := signal.NotifyContext(ctx, os.Interrupt, syscall.SIGTERM)
defer stop()

Expand All @@ -161,25 +143,6 @@ func (s *Server) Run(ctx context.Context) error {
return nil
}

func healthCheck(ctx context.Context, addr string) error {
conn, err := getGRPCConn(context.Background(), addr)
if err != nil {
return err
}
defer conn.Close()

client := grpc_health_v1.NewHealthClient(conn)
res, err := client.Check(ctx, &grpc_health_v1.HealthCheckRequest{})
if err != nil {
return err
}
if res.Status != grpc_health_v1.HealthCheckResponse_SERVING {
return fmt.Errorf("returned status is '%v'", res.Status)
}

return nil
}

func (s *Server) newFindingClient(svcAddr string) (finding.FindingServiceClient, error) {
ctx := context.Background()
conn, err := getGRPCConn(ctx, svcAddr)
Expand Down

0 comments on commit 2b27f76

Please sign in to comment.