Fix tracker statistics
This commit is contained in:
parent
329e885da7
commit
3de13a2e6d
1 changed files with 8 additions and 6 deletions
|
@ -67,6 +67,8 @@ class SiteAnnouncer(object):
|
||||||
def announce(self, force=False, mode="start", pex=True):
|
def announce(self, force=False, mode="start", pex=True):
|
||||||
if time.time() < self.time_last_announce + 30 and not force:
|
if time.time() < self.time_last_announce + 30 and not force:
|
||||||
return # No reannouncing within 30 secs
|
return # No reannouncing within 30 secs
|
||||||
|
if force:
|
||||||
|
self.site.log.debug("Force reannounce in mode %s" % mode)
|
||||||
|
|
||||||
self.fileserver_port = config.fileserver_port
|
self.fileserver_port = config.fileserver_port
|
||||||
self.time_last_announce = time.time()
|
self.time_last_announce = time.time()
|
||||||
|
@ -111,10 +113,11 @@ class SiteAnnouncer(object):
|
||||||
announced_to = trackers[0]
|
announced_to = trackers[0]
|
||||||
else:
|
else:
|
||||||
announced_to = "%s/%s trackers" % (num_announced, len(threads))
|
announced_to = "%s/%s trackers" % (num_announced, len(threads))
|
||||||
self.site.log.debug(
|
if mode != "update" or config.verbose:
|
||||||
"Announced in mode %s to %s in %.3fs, errors: %s, slow: %s" %
|
self.site.log.debug(
|
||||||
(mode, announced_to, time.time() - s, errors, slow)
|
"Announced in mode %s to %s in %.3fs, errors: %s, slow: %s" %
|
||||||
)
|
(mode, announced_to, time.time() - s, errors, slow)
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
if len(threads) > 1:
|
if len(threads) > 1:
|
||||||
self.site.log.error("Announce to %s trackers in %.3fs, failed" % (num_announced, time.time() - s))
|
self.site.log.error("Announce to %s trackers in %.3fs, failed" % (num_announced, time.time() - s))
|
||||||
|
@ -146,7 +149,7 @@ class SiteAnnouncer(object):
|
||||||
self.stats[tracker] = {"status": "", "num_request": 0, "num_success": 0, "num_error": 0, "time_request": 0}
|
self.stats[tracker] = {"status": "", "num_request": 0, "num_success": 0, "num_error": 0, "time_request": 0}
|
||||||
|
|
||||||
self.stats[tracker]["status"] = "announcing"
|
self.stats[tracker]["status"] = "announcing"
|
||||||
self.stats[tracker]["time_status"] = time.time()
|
self.stats[tracker]["time_request"] = time.time()
|
||||||
self.stats[tracker]["num_request"] += 1
|
self.stats[tracker]["num_request"] += 1
|
||||||
if config.verbose:
|
if config.verbose:
|
||||||
self.site.log.debug("Tracker announcing to %s (mode: %s)" % (tracker, mode))
|
self.site.log.debug("Tracker announcing to %s (mode: %s)" % (tracker, mode))
|
||||||
|
@ -177,7 +180,6 @@ class SiteAnnouncer(object):
|
||||||
self.stats[tracker]["status"] = "announced"
|
self.stats[tracker]["status"] = "announced"
|
||||||
self.stats[tracker]["time_status"] = time.time()
|
self.stats[tracker]["time_status"] = time.time()
|
||||||
self.stats[tracker]["num_success"] += 1
|
self.stats[tracker]["num_success"] += 1
|
||||||
self.updateWebsocket(tracker="success")
|
|
||||||
|
|
||||||
if peers is None: # No peers returned
|
if peers is None: # No peers returned
|
||||||
return time.time() - s
|
return time.time() - s
|
||||||
|
|
Loading…
Reference in a new issue