about summary refs log tree commit diff
path: root/src/main.go
blob: b97470492c71bcb57c2eb58c957c15b5d64f8750 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package main

import (
	"flag"
	"log"
	"time"
)

var (
	port *int

	// map the username to the amount of challenges solved
	// TODO: challenges should get a score and the score should be exposed
	// instead of "solved" or "not solved".
	userScore map[string]int
)

func main() {

	// parse the command line flags
	parseFlags()

	// periocically get the stats from all companion containers
	go func() {
		for {
			// get stats
			listDockerContainers()
			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()
}