forked from Team254/cheesy-arena
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
45 lines (37 loc) · 951 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
// Copyright 2014 Team 254. All Rights Reserved.
// Author: [email protected] (Patrick Fairbank)
package main
import (
"log"
"math/rand"
"time"
)
const eventDbPath = "./event.db"
var db *Database
var eventSettings *EventSettings
// Main entry point for the application.
func main() {
rand.Seed(time.Now().UnixNano())
initDb()
// Run the webserver and DS packet listener in goroutines and use the main one for the arena state machine.
go ServeWebInterface()
go ListenForDriverStations()
go ListenForDsUdpPackets()
go MonitorBandwidth()
mainArena.Setup()
mainArena.Run()
}
// Opens the database and stores a handle to it in a global variable.
func initDb() {
var err error
db, err = OpenDatabase(eventDbPath)
checkErr(err)
eventSettings, err = db.GetEventSettings()
checkErr(err)
}
// Logs and exits the application if the given error is not nil.
func checkErr(err error) {
if err != nil {
log.Fatalln("Error: ", err)
}
}