MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / main

Function main

cmd/cql-proxy/main.go:54–112  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

52}
53
54func main() {
55 log.SetLevel(log.DebugLevel)
56 flag.Parse()
57 if showVersion {
58 fmt.Printf("%v %v %v %v %v\n",
59 name, version, runtime.GOOS, runtime.GOARCH, runtime.Version())
60 os.Exit(0)
61 }
62
63 configFile = utils.HomeDirExpand(configFile)
64
65 flag.Visit(func(f *flag.Flag) {
66 log.Infof("args %#v : %s", f.Name, f.Value)
67 })
68
69 // init client
70 var err error
71 if err = client.Init(configFile, []byte(password)); err != nil {
72 log.WithError(err).Error("init covenantsql client failed")
73 os.Exit(-1)
74 return
75 }
76
77 // load proxy config from same config file
78 var cfg *config.Config
79
80 if cfg, err = config.LoadConfig(listenAddr, configFile); err != nil {
81 log.WithError(err).Error("read config failed")
82 os.Exit(-1)
83 return
84 }
85
86 // init server
87 var (
88 server *http.Server
89 afterShutdown func()
90 )
91 if server, afterShutdown, err = initServer(cfg); err != nil {
92 log.WithError(err).Error("init server failed")
93 os.Exit(-1)
94 return
95 }
96
97 go func() {
98 _ = server.ListenAndServe()
99 }()
100
101 log.Info("started proxy")
102
103 <-utils.WaitForExit()
104
105 // stop faucet api
106 ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
107 defer cancel()
108
109 _ = server.Shutdown(ctx)
110 afterShutdown()
111 log.Info("stopped proxy")

Callers

nothing calls this directly

Calls 12

SetLevelFunction · 0.92
HomeDirExpandFunction · 0.92
InfofFunction · 0.92
InitFunction · 0.92
WithErrorFunction · 0.92
LoadConfigFunction · 0.92
InfoFunction · 0.92
WaitForExitFunction · 0.92
initServerFunction · 0.85
ErrorMethod · 0.80
PrintfMethod · 0.45
ShutdownMethod · 0.45

Tested by

no test coverage detected