MCPcopy Create free account
hub / github.com/IceFireDB/IceFireDB / main

Function main

IceFireDB-SQLProxy/main.go:17–61  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15)
16
17func main() {
18 app := cli.NewApp()
19
20 app.Name = "IceFireDB-SQLProxy"
21
22 app.Flags = []cli.Flag{
23 cli.StringFlag{
24 Name: "config, c",
25 Usage: "config file path",
26 Value: "config/config.yaml",
27 Required: false,
28 },
29 cli.StringFlag{
30 Name: "log,l",
31 Usage: "log level: debug,info,warning,error",
32 Value: "info",
33 },
34 }
35
36 app.Before = func(c *cli.Context) error {
37 log.SetFlags(log.Llongfile)
38 // init log
39 lv, err := logrus.ParseLevel(c.String("log"))
40 if err != nil {
41 return err
42 }
43 logrus.SetLevel(lv)
44 // init config
45 confPath := c.String("config")
46 config.InitConfig(confPath)
47 return nil
48 }
49 app.Action = func(c *cli.Context) error {
50 ctx, cancel := context.WithCancel(context.Background())
51 go exitSignal(cancel)
52 if err := mysql.Run(ctx); err != nil {
53 return err
54 }
55 return nil
56 }
57 if err := app.Run(os.Args); err != nil {
58 logrus.Errorf("failed to run application: %v", err)
59 os.Exit(1)
60 }
61}
62
63func exitSignal(cancel context.CancelFunc) {
64 sigs := make(chan os.Signal, 1)

Callers

nothing calls this directly

Calls 6

InitConfigFunction · 0.92
RunFunction · 0.92
exitSignalFunction · 0.70
StringMethod · 0.65
RunMethod · 0.45
ExitMethod · 0.45

Tested by

no test coverage detected