Select Git revision
-
ale authored
The app is now self-hosted instead of relying on the static-content standalone server, so we can eventually add dynamic code for graph serving. The static content serving has improved, with more consistent cache header management, as well as the capability of serving pre-compressed content. Additional code to implement the generation of dependency (flow) graphs in dot format was added (not hooked to the HTTP server yet).
ale authoredThe app is now self-hosted instead of relying on the static-content standalone server, so we can eventually add dynamic code for graph serving. The static content serving has improved, with more consistent cache header management, as well as the capability of serving pre-compressed content. Additional code to implement the generation of dependency (flow) graphs in dot format was added (not hooked to the HTTP server yet).
main.go 1.00 KiB
package main
import (
"flag"
"io/ioutil"
"log"
"os"
"os/exec"
"strings"
floatschema "git.autistici.org/ai3/tools/float-dashboard/schema/float"
"git.autistici.org/ai3/tools/float-dashboard/schema/graph"
"gopkg.in/yaml.v3"
)
var service = flag.String("service", "", "filter this service only")
func main() {
log.SetFlags(0)
flag.Parse()
data, err := ioutil.ReadFile(flag.Arg(0))
if err != nil {
log.Fatal(err)
}
var svcmap map[string]*floatschema.Service
if err := yaml.Unmarshal(data, &svcmap); err != nil {
log.Fatal(err)
}
var dot string
g := graph.ServiceGraph(svcmap)
if *service != "" {
g = g.Filter(graph.FilterEdgeByService(*service))
dot = g.Render(
graph.StyleNodeByService(*service),
graph.StyleEdgeByService(*service),
)
} else {
dot = g.Render(nil, nil)
}
// Run graphviz to render to SVG.
cmd := exec.Command("dot", "-Tsvg")
cmd.Stdin = strings.NewReader(dot)
cmd.Stderr = os.Stderr
cmd.Stdout = os.Stdout
if err := cmd.Run(); err != nil {
log.Fatal(err)
}
}