mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-08-06 06:10:54 +00:00
add build stamp to /stats
This commit is contained in:
parent
6cadcffd5c
commit
976a2593eb
2 changed files with 16 additions and 3 deletions
|
@ -14,6 +14,9 @@ import (
|
||||||
var configFilename = flag.String("config", "config.json", "Configuration file, including the keypairs for the NaCl crypto library, for communicating with the backend.")
|
var configFilename = flag.String("config", "config.json", "Configuration file, including the keypairs for the NaCl crypto library, for communicating with the backend.")
|
||||||
var flagGenerateKeys = flag.Bool("genkeys", false, "Generate NaCl keys instead of serving requests.\nArguments: [int serverId] [base64 backendPublic]\nThe backend public key can either be specified in base64 on the command line, or put in the json file later.")
|
var flagGenerateKeys = flag.Bool("genkeys", false, "Generate NaCl keys instead of serving requests.\nArguments: [int serverId] [base64 backendPublic]\nThe backend public key can either be specified in base64 on the command line, or put in the json file later.")
|
||||||
|
|
||||||
|
var BuildTime string = "build not stamped"
|
||||||
|
var BuildHash string = "build not stamped"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
@ -50,6 +53,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
server.SetupServerAndHandle(conf, nil)
|
server.SetupServerAndHandle(conf, nil)
|
||||||
|
server.SetBuildStamp(BuildTime, BuildHash)
|
||||||
|
|
||||||
go commandLineConsole()
|
go commandLineConsole()
|
||||||
|
|
||||||
|
|
|
@ -11,9 +11,13 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type StatsData struct {
|
type StatsData struct {
|
||||||
Version int
|
StatsDataVersion int
|
||||||
|
|
||||||
StartTime time.Time
|
StartTime time.Time
|
||||||
Uptime time.Duration
|
Uptime time.Duration
|
||||||
|
BuildTime string
|
||||||
|
BuildHash string
|
||||||
|
|
||||||
CachedStatsLastUpdate time.Time
|
CachedStatsLastUpdate time.Time
|
||||||
|
|
||||||
CurrentClientCount uint64
|
CurrentClientCount uint64
|
||||||
|
@ -50,7 +54,7 @@ type StatsData struct {
|
||||||
// I don't really care.
|
// I don't really care.
|
||||||
var Statistics = newStatsData()
|
var Statistics = newStatsData()
|
||||||
|
|
||||||
const StatsDataVersion = 3
|
const StatsDataVersion = 4
|
||||||
const pageSize = 4096
|
const pageSize = 4096
|
||||||
|
|
||||||
var cpuUsage struct {
|
var cpuUsage struct {
|
||||||
|
@ -64,10 +68,15 @@ func newStatsData() *StatsData {
|
||||||
CommandsIssuedMap: make(map[Command]uint64),
|
CommandsIssuedMap: make(map[Command]uint64),
|
||||||
DisconnectCodes: make(map[string]uint64),
|
DisconnectCodes: make(map[string]uint64),
|
||||||
DisconnectReasons: make(map[string]uint64),
|
DisconnectReasons: make(map[string]uint64),
|
||||||
Version: StatsDataVersion,
|
StatsDataVersion: StatsDataVersion,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SetBuildStamp(buildTime, buildHash string) {
|
||||||
|
Statistics.BuildTime = buildTime
|
||||||
|
Statistics.BuildHash = buildHash
|
||||||
|
}
|
||||||
|
|
||||||
func updateStatsIfNeeded() {
|
func updateStatsIfNeeded() {
|
||||||
if time.Now().Add(-2 * time.Second).After(Statistics.CachedStatsLastUpdate) {
|
if time.Now().Add(-2 * time.Second).After(Statistics.CachedStatsLastUpdate) {
|
||||||
updatePeriodicStats()
|
updatePeriodicStats()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue