0.3.6
This commit is contained in:
1 parent
c85c9fc144
commit
50b53e72f0
5 files changed
+21
-2
No files matched your search
@@ -2,6 +2,9 @@
|
|||||||
APP_SECRET=CHANGE_ME_TO_A_LONG_RANDOM_SECRET
|
APP_SECRET=CHANGE_ME_TO_A_LONG_RANDOM_SECRET
|
||||||
LISTEN_ADDR=0.0.0.0:8080
|
LISTEN_ADDR=0.0.0.0:8080
|
||||||
HTTPS_ONLY=true
|
HTTPS_ONLY=true
|
||||||
|
# Verbose per-cycle stats-collector logging (raw TS3 reading vs what got
|
||||||
|
# written to the RRD). Noisy, meant for troubleshooting only.
|
||||||
|
DEBUG=false
|
||||||
|
|
||||||
# Origins allowed to embed /embed/channel in an iframe. Space-separated, origins only.
|
# Origins allowed to embed /embed/channel in an iframe. Space-separated, origins only.
|
||||||
FRAME_ANCESTORS=https://www.example.org
|
FRAME_ANCESTORS=https://www.example.org
|
||||||
|
|||||||
+11
-1
@@ -66,14 +66,24 @@ func collect(ctx context.Context, cfg config.Config, tq *ts3.Query, rm *rrd.Mana
|
|||||||
// more than it reads as useful information -- so, deliberately,
|
// more than it reads as useful information -- so, deliberately,
|
||||||
// a true "server went empty for a while" no longer shows as 0 in
|
// a true "server went empty for a while" no longer shows as 0 in
|
||||||
// the graph, same trade-off the original app made.
|
// the graph, same trade-off the original app made.
|
||||||
|
raw := n
|
||||||
if n == 0 {
|
if n == 0 {
|
||||||
c2, cancel2 := context.WithTimeout(ctx, 2*time.Second)
|
c2, cancel2 := context.WithTimeout(ctx, 2*time.Second)
|
||||||
last, lastErr := rm.Last(c2)
|
last, lastErr := rm.Last(c2)
|
||||||
cancel2()
|
cancel2()
|
||||||
if lastErr == nil {
|
if lastErr != nil {
|
||||||
|
log.Printf("collect: raw=0, rrd lastupdate failed (writing raw 0): %v", lastErr)
|
||||||
|
} else {
|
||||||
n = last
|
n = last
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// DEBUG=1 turns on a log line for every single collection cycle
|
||||||
|
// (raw TS3 reading vs. what actually got written to the RRD) --
|
||||||
|
// useful while diagnosing the stats collector, far too noisy to
|
||||||
|
// leave on permanently (one line per STATS_INTERVAL, forever).
|
||||||
|
if cfg.Debug {
|
||||||
|
log.Printf("collect: raw=%d written=%d", raw, n)
|
||||||
|
}
|
||||||
c3, cancel3 := context.WithTimeout(ctx, 5*time.Second)
|
c3, cancel3 := context.WithTimeout(ctx, 5*time.Second)
|
||||||
defer cancel3()
|
defer cancel3()
|
||||||
if err := rm.Update(c3, n); err != nil {
|
if err := rm.Update(c3, n); err != nil {
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ type Config struct {
|
|||||||
ListenAddr string
|
ListenAddr string
|
||||||
AppSecret string
|
AppSecret string
|
||||||
HTTPSOnly bool
|
HTTPSOnly bool
|
||||||
|
Debug bool
|
||||||
FrameAncestors []string
|
FrameAncestors []string
|
||||||
TrustedProxies []*net.IPNet
|
TrustedProxies []*net.IPNet
|
||||||
TSQueryHost string
|
TSQueryHost string
|
||||||
@@ -39,6 +40,7 @@ func Load() (Config, error) {
|
|||||||
return c, errors.New("APP_SECRET must contain at least 32 characters")
|
return c, errors.New("APP_SECRET must contain at least 32 characters")
|
||||||
}
|
}
|
||||||
c.HTTPSOnly = envBool("HTTPS_ONLY", true)
|
c.HTTPSOnly = envBool("HTTPS_ONLY", true)
|
||||||
|
c.Debug = envBool("DEBUG", false)
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
c.FrameAncestors, err = frameAncestors(os.Getenv("FRAME_ANCESTORS"))
|
c.FrameAncestors, err = frameAncestors(os.Getenv("FRAME_ANCESTORS"))
|
||||||
|
|||||||
@@ -27,3 +27,7 @@ RRDTOOL=rrdtool
|
|||||||
RRD_PATH=/var/lib/ts3monolith/online.rrd
|
RRD_PATH=/var/lib/ts3monolith/online.rrd
|
||||||
GRAPH_DIR=/var/lib/ts3monolith/graphs
|
GRAPH_DIR=/var/lib/ts3monolith/graphs
|
||||||
STATS_INTERVAL=60s
|
STATS_INTERVAL=60s
|
||||||
|
# Szczegolowy log kazdego cyklu zbierania statystyk (surowy odczyt z TS3 vs
|
||||||
|
# co faktycznie trafilo do RRD). Przydatne tylko przy diagnozowaniu -- zalewa
|
||||||
|
# journald jednym wpisem na STATS_INTERVAL, zostaw wylaczone na co dzien.
|
||||||
|
DEBUG=false
|
||||||
Reference in new issue
Block a user