Skip to content
Open
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
8 changes: 5 additions & 3 deletions core/service/serviceconf.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ func (sc ServiceConf) SetUp() error {
}
trace.StartAgent(sc.Telemetry)
proc.Setup(sc.Shutdown)
proc.AddShutdownListener(func() {
trace.StopAgent()
})

if len(sc.MetricsUrl) > 0 {
stat.SetReportWriter(stat.NewRemoteWriter(sc.MetricsUrl))
Expand All @@ -80,6 +77,11 @@ func (sc ServiceConf) SetUp() error {
return nil
}

// TearDown tear down the service.
func (sc ServiceConf) TearDown() {
trace.StopAgent()
}

func (sc ServiceConf) initMode() {
switch sc.Mode {
case DevMode, TestMode, RtMode, PreMode:
Expand Down
2 changes: 2 additions & 0 deletions core/service/serviceconf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func TestServiceConf(t *testing.T) {
HealthPath: "/healthz",
},
}
defer c.TearDown()
c.MustSetUp()
}

Expand All @@ -32,5 +33,6 @@ func TestServiceConfWithMetricsUrl(t *testing.T) {
Mode: "dev",
MetricsUrl: "http://localhost:8080",
}
defer c.TearDown()
assert.NoError(t, c.SetUp())
}
1 change: 1 addition & 0 deletions rest/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ func (s *Server) StartWithOpts(opts ...StartOption) {

// Stop stops the Server.
func (s *Server) Stop() {
s.ngin.conf.TearDown()
logx.Close()
}

Expand Down
3 changes: 3 additions & 0 deletions zrpc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (

// A RpcServer is a rpc server.
type RpcServer struct {
conf RpcServerConf
server internal.Server
register internal.RegisterFn
}
Expand Down Expand Up @@ -57,6 +58,7 @@ func NewServer(c RpcServerConf, register internal.RegisterFn) (*RpcServer, error
}

rpcServer := &RpcServer{
conf: c,
server: server,
register: register,
}
Expand Down Expand Up @@ -94,6 +96,7 @@ func (rs *RpcServer) Start() {

// Stop stops the RpcServer.
func (rs *RpcServer) Stop() {
rs.conf.TearDown()
logx.Close()
}

Expand Down