-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
66 lines (62 loc) · 1.37 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
56
57
58
59
60
61
62
63
64
65
66
package main
import (
"context"
"os"
"github.com/pupi94/madara/cmd"
"github.com/pupi94/madara/config"
"github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"
)
func main() {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
app := &cli.App{
Commands: []*cli.Command{
{
Name: "grpc",
Usage: "Start grpc service",
Action: func(c *cli.Context) error {
config.InitDB()
//config.InitKafkaProducer(ctx)
return cmd.StartGrpcServer(ctx)
},
},
{
Name: "consume_image",
Usage: "consume image",
Action: func(c *cli.Context) error {
return cmd.ConsumeImage(ctx)
},
},
{
Name: "db:migrate",
Usage: "migrate database. db:migrate up OR db:migrate down. Default up",
Action: func(c *cli.Context) error {
var direction = c.Args().First()
config.InitDB()
return cmd.DbMigrate(ctx, direction, c.Int("step"))
},
Flags: []cli.Flag{
&cli.IntFlag{
Name: "step",
Usage: "db migrate up or down step",
Value: 1,
},
},
},
{
Name: "db:generate_migration",
Usage: "generate migration",
Action: func(c *cli.Context) error {
var name = c.Args().First()
config.InitDB()
return cmd.GenerateMigration(ctx, name)
},
},
},
}
err := app.Run(os.Args)
if err != nil {
logrus.WithError(err).Fatal("App start fail....")
}
}