vitess.io/vitess@v0.16.2/go/cmd/vtctld/main.go (about) 1 /* 2 Copyright 2019 The Vitess Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreedto in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package main 18 19 import ( 20 "github.com/spf13/pflag" 21 22 "vitess.io/vitess/go/acl" 23 "vitess.io/vitess/go/exit" 24 "vitess.io/vitess/go/vt/servenv" 25 "vitess.io/vitess/go/vt/topo" 26 "vitess.io/vitess/go/vt/vtctld" 27 ) 28 29 func init() { 30 servenv.RegisterDefaultFlags() 31 servenv.RegisterFlags() 32 servenv.RegisterGRPCServerFlags() 33 servenv.RegisterGRPCServerAuthFlags() 34 servenv.RegisterServiceMapFlag() 35 36 servenv.OnParse(func(fs *pflag.FlagSet) { 37 acl.RegisterFlags(fs) 38 }) 39 } 40 41 // used at runtime by plug-ins 42 var ( 43 ts *topo.Server 44 ) 45 46 func main() { 47 servenv.ParseFlags("vtctld") 48 servenv.Init() 49 defer servenv.Close() 50 51 ts = topo.Open() 52 defer ts.Close() 53 54 // Init the vtctld core 55 err := vtctld.InitVtctld(ts) 56 if err != nil { 57 exit.Return(1) 58 } 59 60 // Register http debug/health 61 vtctld.RegisterDebugHealthHandler(ts) 62 63 // Start schema manager service. 64 initSchema() 65 66 // And run the server. 67 servenv.RunDefault() 68 }