Skip to content
This repository was archived by the owner on Jun 21, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 5 additions & 18 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ package main
import (
"bytes"
"context"
_ "expvar" // register /debug/vars
_ "expvar"
"flag"
"fmt"
"html/template"
"log"
"net"
"net/http"
_ "net/http/pprof" // register /debug/pprof
_ "net/http/pprof"
"os"
"os/signal"
"strings"
Expand All @@ -44,7 +44,6 @@ import (
"github.com/sirupsen/logrus"
"golang.org/x/sys/unix"
"google.golang.org/grpc"
channelz "google.golang.org/grpc/channelz/service"
"google.golang.org/grpc/grpclog"
"google.golang.org/grpc/reflection"
"gopkg.in/reform.v1"
Expand Down Expand Up @@ -133,9 +132,7 @@ func runGRPCServer(ctx context.Context, deps *serviceDependencies) {
grpc.UnaryInterceptor(interceptors.Unary),
grpc.StreamInterceptor(interceptors.Stream),
)
serverAPI.RegisterServerServer(gRPCServer, handlers.NewServerServer(
version.Version,
))
serverAPI.RegisterServerServer(gRPCServer, handlers.NewServerServer(version.Version))
agentAPI.RegisterAgentServer(gRPCServer, &handlers.AgentServer{
Registry: deps.agentsRegistry,
})
Expand All @@ -151,15 +148,13 @@ func runGRPCServer(ctx context.Context, deps *serviceDependencies) {
))

if *debugF {
l.Debug("Reflection and channelz are enabled.")
l.Debug("Reflection enabled.")
reflection.Register(gRPCServer)
channelz.RegisterChannelzServiceToServer(gRPCServer)
}

grpc_prometheus.EnableHandlingTimeHistogram()
grpc_prometheus.Register(gRPCServer)

// run server until it is stopped gracefully or not
listener, err := net.Listen("tcp", *gRPCAddrF)
if err != nil {
l.Panic(err)
Expand All @@ -176,8 +171,6 @@ func runGRPCServer(ctx context.Context, deps *serviceDependencies) {
}()

<-ctx.Done()

// try to stop server gracefully, then not
ctx, cancel := context.WithTimeout(context.Background(), shutdownTimeout)
go func() {
<-ctx.Done()
Expand Down Expand Up @@ -242,13 +235,7 @@ func runDebugServer(ctx context.Context, collectors ...prom.Collector) {

l := logrus.WithField("component", "debug")

handlers := []string{
"/debug/metrics", // by http.Handle above
"/debug/vars", // by expvar
"/debug/requests", // by golang.org/x/net/trace imported by google.golang.org/grpc
"/debug/events", // by golang.org/x/net/trace imported by google.golang.org/grpc
"/debug/pprof", // by net/http/pprof
}
handlers := []string{"/debug/metrics", "/debug/vars", "/debug/requests", "/debug/events", "/debug/pprof"}
for i, h := range handlers {
handlers[i] = "http://" + *debugAddrF + h
}
Expand Down
Loading