-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
55 lines (43 loc) · 1.73 KB
/
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
51
52
53
54
55
package main
import (
"log"
"net/http"
_ "net/http/pprof"
"github.com/TF2Stadium/fumble/database"
"github.com/TF2Stadium/fumble/mumble"
"github.com/TF2Stadium/fumble/rpc"
"github.com/kelseyhightower/envconfig"
"github.com/layeh/gumble/gumble"
)
func main() {
var config struct {
MumbleAddress string `envconfig:"MUMBLE_ADDR" default:"127.0.0.1:64738"`
MumbleUsername string `envconfig:"MUMBLE_USERNAME" default:"SuperUser"`
MumblePassword string `envconfig:"MUMBLE_PASSWORD" required:"true"`
DBAddr string `envconfig:"DATABASE_ADDR" default:"127.0.0.1:5432"`
DBName string `envconfig:"DATABASE_NAME" default:"tf2stadium"`
DBUsername string `envconfig:"DATABASE_USERNAME" default:"tf2stadium"`
DBPassword string `envconfig:"DATABASE_PASSWORD" default:"dickbutt"`
RabbitMQURL string `envconfig:"RABBITMQ_URL" default:"amqp://guest:guest@localhost:5672/"`
RabbitMQEventQueue string `envconfig:"RABBITMQ_EVENT_QUEUE" default:"events"`
RabbitMQRPCQueue string `envconfig:"RABBITMQ_RPC_QUEUE" default:"fumble"`
ProfilerAddr string `envconfig:"PROFILER_ADDR"`
}
log.SetFlags(log.Lshortfile)
err := envconfig.Process("FUMBLE", &config)
if err != nil {
log.Fatal(err)
}
database.Connect(config.DBAddr, config.DBName, config.DBUsername, config.DBPassword)
mumbleConf := gumble.NewConfig()
mumbleConf.Username = config.MumbleUsername
mumbleConf.Password = config.MumblePassword
if config.ProfilerAddr != "" {
go func() {
log.Println(http.ListenAndServe(config.ProfilerAddr, nil))
}()
log.Printf("Running profiler at %s", config.ProfilerAddr)
}
mumble.Connect(mumbleConf, config.MumbleAddress, config.RabbitMQURL, config.RabbitMQEventQueue)
rpc.StartRPC(config.RabbitMQURL, config.RabbitMQRPCQueue)
}