added Close to tracker
This commit is contained in:
parent
7faa1b08ac
commit
e78dc74990
2 changed files with 19 additions and 0 deletions
|
@ -80,4 +80,8 @@ func Serve(cfg *config.Config, tkr *tracker.Tracker) {
|
||||||
|
|
||||||
glog.V(0).Info("Starting on ", cfg.Addr)
|
glog.V(0).Info("Starting on ", cfg.Addr)
|
||||||
graceful.Run(cfg.Addr, cfg.RequestTimeout.Duration, newRouter(srv))
|
graceful.Run(cfg.Addr, cfg.RequestTimeout.Duration, newRouter(srv))
|
||||||
|
err := srv.tracker.Close()
|
||||||
|
if err != nil {
|
||||||
|
glog.Errorf("Failed to shutdown tracker cleanly: %s", err.Error())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,21 @@ func New(cfg *config.Config) (*Tracker, error) {
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Close gracefully shutdowns a Tracker by closing any database connections.
|
||||||
|
func (tkr *Tracker) Close() (err error) {
|
||||||
|
err = tkr.Pool.Close()
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = tkr.backend.Close()
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Writer serializes a tracker's responses, and is implemented for each
|
// Writer serializes a tracker's responses, and is implemented for each
|
||||||
// response transport used by the tracker.
|
// response transport used by the tracker.
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in a new issue