- Add more indepth stats like number of torrents, profile details etc

- Add torrent ingest endpoints
- Add issue template
This commit is contained in:
Mukhtar Akere
2025-05-29 04:05:44 +01:00
parent f9c49cbbef
commit 1cd09239f9
25 changed files with 411 additions and 369 deletions

View File

@@ -9,12 +9,10 @@ import (
"github.com/rs/zerolog"
"github.com/sirrobot01/decypharr/internal/config"
"github.com/sirrobot01/decypharr/internal/logger"
"github.com/sirrobot01/decypharr/internal/request"
"io"
"net/http"
"net/url"
"os"
"runtime"
)
type Server struct {
@@ -45,8 +43,12 @@ func New(handlers map[string]http.Handler) *Server {
//logs
r.Get("/logs", s.getLogs)
//stats
r.Get("/stats", s.getStats)
//debugs
r.Route("/debug", func(r chi.Router) {
r.Get("/stats", s.handleStats)
r.Get("/ingests", s.handleIngests)
r.Get("/ingests/{debrid}", s.handleIngestsByDebrid)
})
//webhooks
r.Post("/webhooks/tautulli", s.handleTautulli)
@@ -108,29 +110,3 @@ func (s *Server) getLogs(w http.ResponseWriter, r *http.Request) {
return
}
}
func (s *Server) getStats(w http.ResponseWriter, r *http.Request) {
var memStats runtime.MemStats
runtime.ReadMemStats(&memStats)
stats := map[string]interface{}{
// Memory stats
"heap_alloc_mb": fmt.Sprintf("%.2fMB", float64(memStats.HeapAlloc)/1024/1024),
"total_alloc_mb": fmt.Sprintf("%.2fMB", float64(memStats.TotalAlloc)/1024/1024),
"memory_used": fmt.Sprintf("%.2fMB", float64(memStats.Sys)/1024/1024),
// GC stats
"gc_cycles": memStats.NumGC,
// Goroutine stats
"goroutines": runtime.NumGoroutine(),
// System info
"num_cpu": runtime.NumCPU(),
// OS info
"os": runtime.GOOS,
"arch": runtime.GOARCH,
"go_version": runtime.Version(),
}
request.JSONResponse(w, stats, http.StatusOK)
}