-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
50 lines (36 loc) · 909 Bytes
/
main.go
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
46
47
48
49
50
package main
import (
"flag"
"os"
"github.com/apex/log"
"github.com/apex/log/handlers/text"
)
const (
// DefaultUpdateFPS describes the update rate for the game state.
DefaultUpdateFPS = 30.0
// DefaultGopherSize is the size in px for the width and height of the gopher.
DefaultGopherSize = 50
boardSize = 300
// the static file to load
tpl = "index.html"
)
var addr = flag.String("addr", ":8080", "http service address")
var verbose = flag.Bool("v", false, "enable verbose logging")
func main() {
flag.Parse()
log.SetHandler(text.New(os.Stderr))
if *verbose {
log.SetLevel(log.DebugLevel)
} else {
log.SetLevel(log.InfoLevel)
}
if _, err := os.Stat(tpl); os.IsNotExist(err) {
log.WithError(err).Fatal("template provided does not exist")
}
ctx := log.WithFields(log.Fields{
"app": "spacegophers",
})
s := NewServer(ctx, *addr, tpl)
// serve the server
s.Serve()
}