mirror of
https://github.com/sot-tech/mochi.git
synced 2026-05-14 13:08: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)
|
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.
|
||||||
//
|
//
|
||||||
|
|||||||
Reference in New Issue
Block a user