runs and saves config

This commit is contained in:
Jeff Carr 2025-02-15 11:39:25 -06:00
parent 8eed7faa7c
commit 97f29457db
Notes: Jeff Carr 2025-02-15 19:04:51 -06:00
// `autogen:go.mod`

module go.wit.com/apps/zookeeper

go 1.22

toolchain go1.23.6

require (
	go.wit.com/dev/alexflint/arg v1.5.5
	go.wit.com/gui v0.22.26
	go.wit.com/lib/gadgets v0.22.9
	go.wit.com/lib/protobuf/forgepb v0.0.81
	go.wit.com/lib/protobuf/zoopb v0.0.27
	go.wit.com/log v0.22.16
	google.golang.org/protobuf v1.36.5
)

require (
	github.com/destel/rill v0.7.0 // indirect
	github.com/go-cmd/cmd v1.4.3 // indirect
	github.com/google/uuid v1.6.0 // indirect
	go.wit.com/dev/alexflint/scalar v1.2.4 // indirect
	go.wit.com/lib/gui/shell v0.22.26 // indirect
	go.wit.com/lib/protobuf/gitpb v0.0.80 // indirect
	go.wit.com/lib/protobuf/guipb v0.0.2 // indirect
	go.wit.com/widget v1.1.29 // indirect
	golang.org/x/sys v0.30.0 // indirect
)

// `autogen:go.sum`

github.com/destel/rill v0.7.0 h1:LJUbeMACaO+/e8rUNk940kYVESD/dbrhAp6M14IjQ0c=
github.com/destel/rill v0.7.0/go.mod h1:srKuXzvGqINUEGYR5b/iwvW+L9/S35RxVHWGYbXNoO4=
github.com/go-cmd/cmd v1.4.3 h1:6y3G+3UqPerXvPcXvj+5QNPHT02BUw7p6PsqRxLNA7Y=
github.com/go-cmd/cmd v1.4.3/go.mod h1:u3hxg/ry+D5kwh8WvUkHLAMe2zQCaXd00t35WfQaOFk=
github.com/go-test/deep v1.1.0 h1:WOcxcdHcvdgThNXjw0t76K42FXTU7HpNQWHpA2HHNlg=
github.com/go-test/deep v1.1.0/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
go.wit.com/dev/alexflint/arg v1.5.5 h1:c4jgIb4OvHjnCMRNSjOa1sNLl6WDxV6tIkMVezR9hCk=
go.wit.com/dev/alexflint/arg v1.5.5/go.mod h1:nH3F6TJDaAUgnLkC0WgRN/H047YfN1TYKaWPYr6B8lo=
go.wit.com/dev/alexflint/scalar v1.2.4 h1:zmBeEkObwz1lcelwfGNYP2GS6SQ9e0tdv7JdHwMZEEk=
go.wit.com/dev/alexflint/scalar v1.2.4/go.mod h1:kCNO1Fo5LnnK6+qa+zYhP5fdgfC1C+vx1ti99Md+FAM=
go.wit.com/gui v0.22.26 h1:HtdV1kx6wHpCTyS67s2KdMCyX6teNXIQOk1NyX6o8bY=
go.wit.com/gui v0.22.26/go.mod h1:6OVZofoS43VNUiQWR0aJkXEcqpuIhERJQnxhdGrEsHo=
go.wit.com/lib/gadgets v0.22.9 h1:NUrPSCWwFMzt5iXNkEIh9tTkWX6f/4jrCoWosmFmKD8=
go.wit.com/lib/gadgets v0.22.9/go.mod h1:Gf3TM674Nu73xKJzWqindIM43IXPzACB/+YH+NMrh+c=
go.wit.com/lib/gui/shell v0.22.26 h1:F+7aadEujsTgyBEs5ptKGL6N72reDkGd/7b0Ju4HeTU=
go.wit.com/lib/gui/shell v0.22.26/go.mod h1:Km5o+DLU5up5jvTEum9wiTdsZZG/EUNERVzn2wJ6DBE=
go.wit.com/lib/protobuf/forgepb v0.0.81 h1:Y+v99Igi4UzkltNL09sSTGNf5bx6YC5NLW/mBx3ZqRM=
go.wit.com/lib/protobuf/forgepb v0.0.81/go.mod h1:FqVUE6ezeRNbOdQWiy/h6GZYbn8UkgkMFty3mxaCRAk=
go.wit.com/lib/protobuf/gitpb v0.0.80 h1:5AeyG0BVLKWzU9zUt4doEDa7eEh+UKWGEcE1ibhSgqM=
go.wit.com/lib/protobuf/gitpb v0.0.80/go.mod h1:fsefHgERvcJpQ4YMGYOVM7lep+yYH+LsLJolhVWCrjc=
go.wit.com/lib/protobuf/guipb v0.0.2 h1:ZR4cLy+XheRQEFLlissBmASJDqiLfHaAluF6wYbVuOo=
go.wit.com/lib/protobuf/guipb v0.0.2/go.mod h1:mZsirb7zRgsE2IGHuvHkG7j85hkrGZl3NAALOEkjowA=
go.wit.com/lib/protobuf/zoopb v0.0.27 h1:Hse85KN5nxFPkg6dk2Z96kEQRI4I4mQ66cZW0Nf/1so=
go.wit.com/lib/protobuf/zoopb v0.0.27/go.mod h1:CNZmHSG+H41Gw1xuJvW1E4ef5eQCPptzIg1U5nfSGV4=
go.wit.com/log v0.22.16 h1:E0Vd0Z2ILtfjhs7J/CQ4g13DK1jtQiYl6l5KOBGsZoA=
go.wit.com/log v0.22.16/go.mod h1:/c5Uj30sWRQ4B5ei2ElB6Q8Si/cK6v+KbxnH208KD84=
go.wit.com/widget v1.1.29 h1:rURM/N1hbrl0btGlBIUx0SCre9jj+hshvkBLMMa008I=
go.wit.com/widget v1.1.29/go.mod h1:wj7TpAr2gk7Poa+v8XQkH1aidnTdgAa/a8GxrMtcztw=
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM=
google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=

// `autogen:`
2 changed files with 24 additions and 11 deletions

View File

@ -7,8 +7,8 @@ BUILDTIME = $(shell date +%Y.%m.%d_%H%M)
# REDOMOD = $(shell if [ -e go.mod ]; then echo go.mod; else echo no go mod; fi)
REDOMOD = $(shell if [ -e go.sum ]; then echo go.sum exists; else GO111MODULE= go mod init; GO111MODULE= go mod tidy; fi)
all: goimports build nogui
./zookeeper --version
all: goimports build
./zookeeper
nogui:
./zookeeper --gui nocui

View File

@ -13,21 +13,34 @@ import (
"google.golang.org/protobuf/types/known/timestamppb"
)
func rawGetHostname(data []byte) *zoopb.Machine {
newm := new(zoopb.Machine)
newm.Unmarshal(data)
return newm
}
func handleMachine(w http.ResponseWriter, hostname string, data []byte) {
hostname = strings.TrimSpace(hostname)
newm := rawGetHostname(data)
if newm == nil {
log.Info("unmarshal failed on data len =", len(data))
}
if hostname == newm.Hostname {
log.Info("hostname mismatch", hostname, "vs", newm.Hostname)
hostname = newm.Hostname
}
if hostname == "" {
log.Info("something went wrong. hostname is blank")
log.Info("hostname is blank even after unmarshal. data len =", len(data))
return
}
log.Info("lookoing for", hostname)
m := me.machines.FindByHostname(hostname)
if m == nil {
newm := new(zoopb.Machine)
err := newm.Unmarshal(data)
if err != nil {
log.Info("machine Unmarshal() failed", hostname)
return
}
me.machines.Append(newm)
am := new(zoopb.Machine)
am.Hostname = newm.Hostname
am.Memory = newm.Memory
me.machines2.Append(am)
return
}
log.Info("not new machine", hostname)
@ -44,7 +57,7 @@ func updateMachine(u *zoopb.Machine) string {
log.Info("adding new machine", u.Hostname)
me.machines.Append(u)
log.Info("save machines pb file here...")
// me.machines.ConfigSave()
me.machines2.ConfigSave()
return "new"
}
// log.Info("updating machine", m.Hostname)