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
|
FROM golang:1.18-bullseye
|
||||||
|
|
||||||
COPY . /src/orbeat
|
COPY . /src/orbeat
|
||||||
|
COPY .git/ /src/orbeat/.git/
|
||||||
|
|
||||||
WORKDIR /src/orbeat
|
WORKDIR /src/orbeat
|
||||||
RUN GOAMD64=v2 go build -v -o orbeat . && mv orbeat /usr/bin && rm -rf /src/orbeat
|
RUN GOAMD64=v2 go build -v -o orbeat . && mv orbeat /usr/bin && rm -rf /src/orbeat
|
||||||
|
|
|
@ -23,6 +23,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"runtime/debug"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
@ -47,6 +48,8 @@ var trustedPublicKeys []ed25519.PublicKey
|
||||||
|
|
||||||
var debugOutput = false
|
var debugOutput = false
|
||||||
|
|
||||||
|
var programVersion = "unknown"
|
||||||
|
|
||||||
type statistics struct {
|
type statistics struct {
|
||||||
Served servedStatistics `json:"served"`
|
Served servedStatistics `json:"served"`
|
||||||
ContentCache contentCacheStatistics `json:"content_cache"`
|
ContentCache contentCacheStatistics `json:"content_cache"`
|
||||||
|
@ -550,12 +553,14 @@ func handle(ctx httputils.RequestContext) {
|
||||||
ctx.SetResponseCode(http.StatusOK)
|
ctx.SetResponseCode(http.StatusOK)
|
||||||
|
|
||||||
statsStruct := struct {
|
statsStruct := struct {
|
||||||
|
Version string `json:"version"`
|
||||||
Statistics *statistics `json:"statistics"`
|
Statistics *statistics `json:"statistics"`
|
||||||
Database struct {
|
Database struct {
|
||||||
TotalEntries uint64 `json:"entries"`
|
TotalEntries uint64 `json:"entries"`
|
||||||
TotalSize uint64 `json:"size"`
|
TotalSize uint64 `json:"size"`
|
||||||
} `json:"database"`
|
} `json:"database"`
|
||||||
}{
|
}{
|
||||||
|
Version: programVersion,
|
||||||
Statistics: &globalStatistics,
|
Statistics: &globalStatistics,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -717,6 +722,16 @@ func main() {
|
||||||
|
|
||||||
var err error
|
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, ",") {
|
for _, k := range strings.Split(*trustedKeys, ",") {
|
||||||
var publicKey ed25519.PublicKey
|
var publicKey ed25519.PublicKey
|
||||||
publicKey, err = MakyuuIchaival.Bech32Encoding.DecodeString(strings.Trim(k, " "))
|
publicKey, err = MakyuuIchaival.Bech32Encoding.DecodeString(strings.Trim(k, " "))
|
||||||
|
|
Loading…
Reference in a new issue