From d4dce83782b67236d2c8d99ffc9bdc89328bb5de Mon Sep 17 00:00:00 2001 From: Emile Date: Sun, 6 Oct 2019 20:11:44 +0200 Subject: get the status of all other containers --- src/main.go | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/main.go (limited to 'src/main.go') diff --git a/src/main.go b/src/main.go new file mode 100644 index 0000000..a52c043 --- /dev/null +++ b/src/main.go @@ -0,0 +1,42 @@ +package main + +import ( + "flag" + "log" + "time" +) + +var ( + port *int +) + +func main() { + + // parse the command line flags + parseFlags() + + // periocically get the stats from all companion containers + go func() { + for { + // get stats + log.Printf("Fetching the stats") + listDockerContainers() + log.Printf("Done fetching the stats") + time.Sleep(1 * time.Second) + } + }() + + // setup a http server displaying the scoreboard + log.Println("setting up the http server") + httpServer := setupHTTPServer() + + // start the http server + log.Println("Starting the http server") + log.Fatalln(httpServer.ListenAndServe()) +} + +// parseFlags parses the command line flags +func parseFlags() { + port = flag.Int("port", 8080, "Port the http server should run on") + flag.Parse() +} -- cgit 1.4.1