mirror of
https://github.com/sot-tech/mochi.git
synced 2026-05-14 10:38:36 -07:00
added Close to tracker
This commit is contained in:
@@ -80,4 +80,8 @@ func Serve(cfg *config.Config, tkr *tracker.Tracker) {
|
||||
|
||||
glog.V(0).Info("Starting on ", cfg.Addr)
|
||||
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
|
||||
}
|
||||
|
||||
// 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
|
||||
// response transport used by the tracker.
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user