add server version/commit in logs and UI

This commit is contained in:
Mikaël Cluseau 2023-11-04 13:53:00 +01:00
parent 41897c00b4
commit f7b708ce4b
6 changed files with 18 additions and 6 deletions

View File

@ -21,13 +21,15 @@ const (
etcDir = "/etc/direktil"
)
var Version = "dev"
var (
address = flag.String("address", ":7606", "HTTP listen address")
tlsAddress = flag.String("tls-address", "", "HTTPS listen address")
certFile = flag.String("tls-cert", etcDir+"/server.crt", "Server TLS certificate")
keyFile = flag.String("tls-key", etcDir+"/server.key", "Server TLS key")
autoUnlock = flag.String("auto-unlock", "", "Auto-unlock store (testing only!)")
autoUnlock = flag.String("auto-unlock", "", "Auto-unlock store (testing only!) env: DLS_AUTO_UNLOCK")
casStore cas.Store
)
@ -41,6 +43,9 @@ func main() {
log.Fatal("no listen address given")
}
log.Print("Direktil local-server version ", Version)
wPublicState.Change(func(s *PublicState) { s.ServerVersion = Version })
computeUIHash()
openSecretStore()

View File

@ -8,6 +8,7 @@ import (
)
type PublicState struct {
ServerVersion string
UIHash string
Store struct {
New bool

3
hack/build Executable file
View File

@ -0,0 +1,3 @@
#! /bin/sh
set -ex
go build -o dist/ -trimpath -ldflags "-X main.Version=$(git describe --always --dirty)" $*

View File

@ -22,7 +22,8 @@
<button class="link" @click="copyText(session.token)">&#x1F5D0;</button>
</span>
<span id="uiHash">ui <code>{{ uiHash || '-----' }}</code></span>
<span>server <code>{{ serverVersion || '-----' }}</code></span>
<span>ui <code>{{ uiHash || '-----' }}</code></span>
<span :class="publicState ? 'green' : 'red'">&#x1F5F2;</span>
</div>

View File

@ -16,6 +16,7 @@ createApp({
session: {},
error: null,
publicState: null,
serverVersion: null,
uiHash: null,
watchingState: false,
state: null,
@ -41,6 +42,7 @@ createApp({
deep: true,
handler(v) {
if (v) {
this.serverVersion = v.ServerVersion
if (this.uiHash && v.UIHash != this.uiHash) {
console.log("reloading")
location.reload()

View File

@ -3,13 +3,13 @@ modd.conf {}
**/*.go go.mod go.sum {
prep: go test ./...
prep: mkdir -p dist
prep: go build -o dist/ -trimpath ./...
prep: hack/build ./...
#prep: docker build --build-arg GOPROXY=$GOPROXY -t dls .
#daemon +sigterm: /var/lib/direktil/test-run
}
html/**/* {
prep: go build -o dist/ -trimpath ./cmd/dkl-local-server
prep: hack/build ./cmd/dkl-local-server
}
dist/dkl-local-server {