feat: add option for /debug/vars endpoint to expose database and media stats
closes #372 closes #150
This commit is contained in:
@@ -78,6 +78,7 @@ password can then be changed from the web interface
|
|||||||
| `GONIC_EXCLUDE_PATTERN` | `-exclude-pattern` | **optional** files matching this regex pattern will not be imported |
|
| `GONIC_EXCLUDE_PATTERN` | `-exclude-pattern` | **optional** files matching this regex pattern will not be imported |
|
||||||
| `GONIC_MULTI_VALUE_GENRE` | `-multi-value-genre` | **optional** setting for multi-valued genre tags when scanning ([see more](#multi-valued-tags)) |
|
| `GONIC_MULTI_VALUE_GENRE` | `-multi-value-genre` | **optional** setting for multi-valued genre tags when scanning ([see more](#multi-valued-tags)) |
|
||||||
| `GONIC_MULTI_VALUE_ALBUM_ARTIST` | `-multi-value-album-artist` | **optional** setting for multi-valued album artist tags when scanning ([see more](#multi-valued-tags)) |
|
| `GONIC_MULTI_VALUE_ALBUM_ARTIST` | `-multi-value-album-artist` | **optional** setting for multi-valued album artist tags when scanning ([see more](#multi-valued-tags)) |
|
||||||
|
| `GONIC_EXPVAR` | `-expvar` | **optional** enable the /debug/vars endpoint (exposes useful debugging attributes as well as database stats) |
|
||||||
|
|
||||||
## multi valued tags
|
## multi valued tags
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"expvar"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
@@ -78,6 +79,8 @@ func main() {
|
|||||||
set.Var(&confMultiValueGenre, "multi-value-genre", "setting for mutli-valued genre scanning (optional)")
|
set.Var(&confMultiValueGenre, "multi-value-genre", "setting for mutli-valued genre scanning (optional)")
|
||||||
set.Var(&confMultiValueAlbumArtist, "multi-value-album-artist", "setting for mutli-valued album artist scanning (optional)")
|
set.Var(&confMultiValueAlbumArtist, "multi-value-album-artist", "setting for mutli-valued album artist scanning (optional)")
|
||||||
|
|
||||||
|
confExpvar := set.Bool("expvar", false, "enable the /debug/vars endpoint (optional)")
|
||||||
|
|
||||||
deprecatedConfGenreSplit := set.String("genre-split", "", "(deprecated, see multi-value settings)")
|
deprecatedConfGenreSplit := set.String("genre-split", "", "(deprecated, see multi-value settings)")
|
||||||
|
|
||||||
if _, err := regexp.Compile(*confExcludePatterns); err != nil {
|
if _, err := regexp.Compile(*confExcludePatterns); err != nil {
|
||||||
@@ -233,6 +236,19 @@ func main() {
|
|||||||
ctrladmin.AddRoutes(ctrlAdmin, mux.PathPrefix("/admin").Subrouter())
|
ctrladmin.AddRoutes(ctrlAdmin, mux.PathPrefix("/admin").Subrouter())
|
||||||
ctrlsubsonic.AddRoutes(ctrlSubsonic, mux.PathPrefix("/rest").Subrouter())
|
ctrlsubsonic.AddRoutes(ctrlSubsonic, mux.PathPrefix("/rest").Subrouter())
|
||||||
|
|
||||||
|
if *confExpvar {
|
||||||
|
mux.Handle("/debug/vars", expvar.Handler())
|
||||||
|
expvar.Publish("stats", expvar.Func(func() any {
|
||||||
|
var stats struct{ Albums, Tracks, Artists, InternetRadioStations, Podcasts uint }
|
||||||
|
dbc.Model(db.Album{}).Count(&stats.Albums)
|
||||||
|
dbc.Model(db.Track{}).Count(&stats.Tracks)
|
||||||
|
dbc.Model(db.Artist{}).Count(&stats.Artists)
|
||||||
|
dbc.Model(db.InternetRadioStation{}).Count(&stats.InternetRadioStations)
|
||||||
|
dbc.Model(db.Podcast{}).Count(&stats.Podcasts)
|
||||||
|
return stats
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
var g run.Group
|
var g run.Group
|
||||||
g.Add(func() error {
|
g.Add(func() error {
|
||||||
log.Print("starting job 'http'\n")
|
log.Print("starting job 'http'\n")
|
||||||
|
|||||||
Reference in New Issue
Block a user