-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
executable file
·49 lines (44 loc) · 921 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
package main
import (
"fmt"
"github.com/urfave/cli/v2"
botBot "gitlab.com/aoterocom/AOCryptobot/bot"
"gitlab.com/aoterocom/AOCryptobot/helpers"
"gitlab.com/aoterocom/AOCryptobot/interfaces"
"log"
"os"
"time"
)
func main() {
app := &cli.App{
Name: "AOCryptoBot",
Usage: "Advanced crypto trading bot",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "strategies",
Aliases: []string{"s"},
Usage: "strategies list, comma separated",
},
},
Action: func(c *cli.Context) error {
bot := &botBot.Bot{}
rubBot(bot, c)
return nil
},
}
err := app.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}
func rubBot(b interfaces.MarketBot, c *cli.Context) {
// Panic recovery. Relaunch application.
defer func() {
if r := recover(); r != nil {
helpers.Logger.Errorln(fmt.Sprintf("Recovered. Error: %+v", r))
time.Sleep(1 * time.Second)
rubBot(b, c)
}
}()
b.Run(c)
}