Add peer purging test, and ensure the purging routine runs whenever a tracker is created

This commit is contained in:
Justin Li
2014-07-16 20:08:03 -04:00
parent 0f2ed791e5
commit a2e14f79c2
2 changed files with 41 additions and 21 deletions

View File

@@ -36,6 +36,13 @@ func NewTracker(cfg *config.Config) (*Tracker, error) {
return nil, err
}
go tracker.PurgeInactivePeers(
tp,
cfg.PurgeInactiveTorrents,
cfg.Announce.Duration*2,
cfg.Announce.Duration,
)
return &Tracker{
cfg: cfg,
pool: tp,
@@ -99,13 +106,6 @@ func Serve(cfg *config.Config) {
glog.Fatal("New: ", err)
}
go tracker.PurgeInactivePeers(
t.pool,
cfg.PurgeInactiveTorrents,
cfg.Announce.Duration*2,
cfg.Announce.Duration,
)
glog.V(0).Info("Starting on ", cfg.Addr)
graceful.Run(cfg.Addr, cfg.RequestTimeout.Duration, NewRouter(t, cfg))
}