forked from synap5e/stove
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstove.go
43 lines (37 loc) · 891 Bytes
/
stove.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
package main
import (
"fmt"
"github.com/HearthSim/stove/bnet"
"github.com/HearthSim/stove/config"
"github.com/HearthSim/stove/pegasus"
_ "github.com/rakyll/gom/http"
"log"
"net/http"
"strings"
)
func main() {
addr := config.Config.ListenAddress
if !strings.Contains(addr, ":") {
addr = fmt.Sprintf("%s:%d", addr, 1119)
}
if config.Config.Migrate {
fmt.Printf("Performing database migration\n")
bnet.Migrate()
pegasus.Migrate()
return
}
debugListen := config.Config.DebugListenAddress
if len(debugListen) != 0 {
go func() {
log.Printf("Debug http server listening on %s ...\n", debugListen)
log.Println(http.ListenAndServe(debugListen, nil))
}()
}
serv := bnet.NewServer()
serv.RegisterGameServer("WTCG", pegasus.NewServer(serv))
log.Printf("Listening on %s ...\n", addr)
err := serv.ListenAndServe(addr)
if err != nil {
log.Println(err)
}
}