Add Version entry to stats
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
764d3be155
commit
0c4bd412c9
|
@ -1,6 +1,7 @@
|
|||
FROM golang:1.18-bullseye
|
||||
|
||||
COPY . /src/orbeat
|
||||
COPY .git/ /src/orbeat/.git/
|
||||
|
||||
WORKDIR /src/orbeat
|
||||
RUN GOAMD64=v2 go build -v -o orbeat . && mv orbeat /usr/bin && rm -rf /src/orbeat
|
||||
|
|
|
@ -23,6 +23,7 @@ import (
|
|||
"os"
|
||||
"path"
|
||||
"runtime"
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
@ -47,6 +48,8 @@ var trustedPublicKeys []ed25519.PublicKey
|
|||
|
||||
var debugOutput = false
|
||||
|
||||
var programVersion = "unknown"
|
||||
|
||||
type statistics struct {
|
||||
Served servedStatistics `json:"served"`
|
||||
ContentCache contentCacheStatistics `json:"content_cache"`
|
||||
|
@ -550,12 +553,14 @@ func handle(ctx httputils.RequestContext) {
|
|||
ctx.SetResponseCode(http.StatusOK)
|
||||
|
||||
statsStruct := struct {
|
||||
Version string `json:"version"`
|
||||
Statistics *statistics `json:"statistics"`
|
||||
Database struct {
|
||||
TotalEntries uint64 `json:"entries"`
|
||||
TotalSize uint64 `json:"size"`
|
||||
} `json:"database"`
|
||||
}{
|
||||
Version: programVersion,
|
||||
Statistics: &globalStatistics,
|
||||
}
|
||||
|
||||
|
@ -717,6 +722,16 @@ func main() {
|
|||
|
||||
var err error
|
||||
|
||||
if dInfo, ok := debug.ReadBuildInfo(); ok {
|
||||
for _, s := range dInfo.Settings {
|
||||
if s.Key == "vcs.revision" {
|
||||
programVersion = s.Value
|
||||
} else if s.Key == "vcs.modified" {
|
||||
programVersion += "-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for _, k := range strings.Split(*trustedKeys, ",") {
|
||||
var publicKey ed25519.PublicKey
|
||||
publicKey, err = MakyuuIchaival.Bech32Encoding.DecodeString(strings.Trim(k, " "))
|
||||
|
|
Loading…
Reference in a new issue