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" etcDir = "/etc/direktil"
) )
var Version = "dev"
var ( var (
address = flag.String("address", ":7606", "HTTP listen address") address = flag.String("address", ":7606", "HTTP listen address")
tlsAddress = flag.String("tls-address", "", "HTTPS listen address") tlsAddress = flag.String("tls-address", "", "HTTPS listen address")
certFile = flag.String("tls-cert", etcDir+"/server.crt", "Server TLS certificate") certFile = flag.String("tls-cert", etcDir+"/server.crt", "Server TLS certificate")
keyFile = flag.String("tls-key", etcDir+"/server.key", "Server TLS key") 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 casStore cas.Store
) )
@ -41,6 +43,9 @@ func main() {
log.Fatal("no listen address given") log.Fatal("no listen address given")
} }
log.Print("Direktil local-server version ", Version)
wPublicState.Change(func(s *PublicState) { s.ServerVersion = Version })
computeUIHash() computeUIHash()
openSecretStore() openSecretStore()

View File

@ -8,8 +8,9 @@ import (
) )
type PublicState struct { type PublicState struct {
UIHash string ServerVersion string
Store struct { UIHash string
Store struct {
New bool New bool
Open bool Open 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> <button class="link" @click="copyText(session.token)">&#x1F5D0;</button>
</span> </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> <span :class="publicState ? 'green' : 'red'">&#x1F5F2;</span>
</div> </div>

View File

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

View File

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