-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
46 lines (40 loc) · 913 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
package main
import (
"os"
log "github.com/Sirupsen/logrus"
"github.com/eternnoir/gbf-bike/bike"
"github.com/eternnoir/gbf-bike/server"
"github.com/urfave/cli"
)
// InitApp function is use to create new cli.App.
func InitApp() *cli.App {
app := cli.NewApp()
app.Name = "GBF Bike"
app.Usage = "GBF Battle grab server."
app.Flags = cmdFlags
app.Action = func(c *cli.Context) error {
return Start(c)
}
return app
}
func Start(c *cli.Context) error {
if Debug {
log.Warn("Use debug mode")
log.SetLevel(log.DebugLevel)
}
gb, err := bike.NewGbfBike(ConsumerKey, ConsumerSecret, AccessToken, AccessTokenSecret)
if err != nil {
return err
}
apiServer := server.NewApi(Port)
gb.AddBattleReceiver(apiServer)
go apiServer.Start()
log.Fatal(gb.Start())
return nil
}
func main() {
app := InitApp()
if err := app.Run(os.Args); err != nil {
log.Errorf("Start GBF Bike Fail %s", err)
}
}