Allow instance rebuild via interface

This commit is contained in:
Tom Wiesing 2022-10-12 16:27:07 +02:00
parent 5e7c5b2d23
commit 1e1d1a3cad
No known key found for this signature in database
2 changed files with 40 additions and 6 deletions

View file

@ -21,6 +21,12 @@ func (info *Info) serveSocket(conn httpx.WebSocketConnection) {
return
}
info.serverSocketSnapshot(string(slug.Bytes), info.socketWriter(conn))
case "rebuild":
slug, ok := <-conn.Read()
if !ok {
return
}
info.serverSocketRebuild(string(slug.Bytes), info.socketWriter(conn))
}
}
@ -61,3 +67,24 @@ func (info *Info) serverSocketSnapshot(slug string, writer *status.LineBuffer) {
stream.Println("Done")
}
func (info *Info) serverSocketRebuild(slug string, writer *status.LineBuffer) {
stream := stream.NewIOStream(writer, writer, nil, 0)
// get the wisski
wissKI, err := info.Instances.WissKI(slug)
if err != nil {
stream.EPrintln(err)
return
}
{
err := wissKI.Build(stream, true)
if err != nil {
stream.EPrintln(err)
return
}
}
stream.Println("Done")
}