new: feat: add metrics endpoint and prometheus monitoring
This commit is contained in:
26
main.go
26
main.go
@@ -5,17 +5,33 @@ import (
|
||||
|
||||
handler "github.com/felipemarinho97/torrent-indexer/api"
|
||||
"github.com/felipemarinho97/torrent-indexer/cache"
|
||||
"github.com/felipemarinho97/torrent-indexer/monitoring"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
)
|
||||
|
||||
func main() {
|
||||
redis := cache.NewRedis()
|
||||
indexers := handler.NewIndexers(redis)
|
||||
metrics := monitoring.NewMetrics()
|
||||
metrics.Register()
|
||||
indexers := handler.NewIndexers(redis, metrics)
|
||||
|
||||
http.HandleFunc("/", handler.HandlerIndex)
|
||||
http.HandleFunc("/indexers/comando_torrents", indexers.HandlerComandoIndexer)
|
||||
http.HandleFunc("/indexers/bludv", indexers.HandlerBluDVIndexer)
|
||||
indexerMux := http.NewServeMux()
|
||||
metricsMux := http.NewServeMux()
|
||||
|
||||
err := http.ListenAndServe(":7006", nil)
|
||||
indexerMux.HandleFunc("/", handler.HandlerIndex)
|
||||
indexerMux.HandleFunc("/indexers/comando_torrents", indexers.HandlerComandoIndexer)
|
||||
indexerMux.HandleFunc("/indexers/bludv", indexers.HandlerBluDVIndexer)
|
||||
|
||||
metricsMux.Handle("/metrics", promhttp.Handler())
|
||||
|
||||
go func() {
|
||||
err := http.ListenAndServe(":8081", metricsMux)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
|
||||
err := http.ListenAndServe(":7006", indexerMux)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user