mirror of
https://github.com/LBRYFoundation/reflector.go.git
synced 2025-08-23 17:27:25 +00:00
reports stats on shutdown
This commit is contained in:
parent
cb386de4c7
commit
59e92ccf88
2 changed files with 9 additions and 3 deletions
|
@ -54,6 +54,9 @@ func NewServer(store store.BlobStore) *Server {
|
|||
// Shutdown shuts down the reflector server gracefully.
|
||||
func (s *Server) Shutdown() {
|
||||
log.Println("shutting down reflector server...")
|
||||
if s.isReportStats() {
|
||||
s.stats.Shutdown()
|
||||
}
|
||||
s.grp.StopAndWait()
|
||||
log.Println("reflector server stopped")
|
||||
}
|
||||
|
@ -83,7 +86,7 @@ func (s *Server) Start(address string) error {
|
|||
}()
|
||||
|
||||
s.stats = newStatLogger(s.StatLogger, s.StatReportFrequency, s.grp.Child())
|
||||
if s.StatLogger != nil && s.StatReportFrequency > 0 {
|
||||
if s.isReportStats() {
|
||||
s.stats.Start()
|
||||
}
|
||||
|
||||
|
@ -367,6 +370,10 @@ func (s *Server) quitting() bool {
|
|||
}
|
||||
}
|
||||
|
||||
func (s *Server) isReportStats() bool {
|
||||
return s.StatLogger != nil && s.StatReportFrequency > 0
|
||||
}
|
||||
|
||||
func BlobHash(blob []byte) string {
|
||||
hashBytes := sha512.Sum384(blob)
|
||||
return hex.EncodeToString(hashBytes[:])
|
||||
|
|
|
@ -12,8 +12,6 @@ import (
|
|||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// TODO: send stats on shutdown
|
||||
|
||||
// TODO: store daily stats too. and maybe other intervals
|
||||
|
||||
type stats struct {
|
||||
|
@ -46,6 +44,7 @@ func (s *stats) Start() {
|
|||
}
|
||||
|
||||
func (s *stats) Shutdown() {
|
||||
s.log()
|
||||
s.grp.StopAndWait()
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue