func main() { flag.Parse() servenv.Init() defer servenv.Close() unmarshalFile(*dbConfigFile, &dbconfig) log.Infof("dbconfig: %s\n", dbconfig) unmarshalFile(*overridesFile, &schemaOverrides) data, _ := json.MarshalIndent(schemaOverrides, "", " ") log.Infof("schemaOverrides: %s\n", data) ts.InitQueryService() ts.AllowQueries(dbconfig, schemaOverrides, ts.LoadCustomRules()) servenv.ServeRPC() log.Infof("starting vtocc %v", *port) s := proc.ListenAndServe(fmt.Sprintf("%v", *port)) // A SIGUSR1 means that we're restarting if s == syscall.SIGUSR1 { // Give some time for the other process // to pick up the listeners time.Sleep(5 * time.Millisecond) ts.DisallowQueries(true) } else { ts.DisallowQueries(false) } }
// zkocc: a proxy for zk func main() { flag.Parse() servenv.Init() defer servenv.Close() servenv.ServeRPC() zkr := zkocc.NewZkReader(*resolveLocal, flag.Args()) zk.RegisterZkReader(zkr) topo.RegisterTopoReader(&TopoReader{zkr: zkr}) proc.ListenAndServe(fmt.Sprintf("%v", *port)) }
func main() { dbconfigs.RegisterFlags() mysqlctl.RegisterFlags() flag.Parse() servenv.Init() defer servenv.Close() log.Infof("started vtaction %v", os.Args) servenv.ServeRPC() mycnf, mycnfErr := mysqlctl.NewMycnfFromFlags(0) if mycnfErr != nil { log.Fatalf("mycnf read failed: %v", mycnfErr) } log.V(6).Infof("mycnf: %v", jscfg.ToJson(mycnf)) dbcfgs, cfErr := dbconfigs.Init(mycnf.SocketFile) if cfErr != nil { log.Fatalf("%s", cfErr) } mysqld := mysqlctl.NewMysqld("Dba", mycnf, &dbcfgs.Dba, &dbcfgs.Repl) defer mysqld.Close() topoServer := topo.GetServer() defer topo.CloseServers() actor := actor.NewTabletActor(mysqld, mysqld, topoServer, topo.TabletAlias{}) // we delegate out startup to the micromanagement server so these actions // will occur after we have obtained our socket. bindAddr := fmt.Sprintf(":%v", *servenv.Port) httpServer := &http.Server{Addr: bindAddr} go func() { if err := httpServer.ListenAndServe(); err != nil { log.Errorf("httpServer.ListenAndServe err: %v", err) } }() actionErr := actor.HandleAction(*actionNode, *action, *actionGuid, *force) if actionErr != nil { log.Fatalf("action error: %v", actionErr) } log.Infof("finished vtaction %v", os.Args) }
func main() { flag.Parse() servenv.Init() defer servenv.Close() if *mycnfFile == "" { log.Fatalf("Please specify the path for mycnf file.") } mycnf, err := mysqlctl.ReadMycnf(*mycnfFile) if err != nil { log.Fatalf("Error reading mycnf file %v", *mycnfFile) } binlogServer := mysqlctl.NewBinlogServer(mycnf) mysqlctl.EnableBinlogServerService(binlogServer, *dbname) proto.RegisterBinlogServer(binlogServer) rpcwrap.RegisterAuthenticated(binlogServer) servenv.ServeRPC() proc.ListenAndServe(fmt.Sprintf("%v", *port)) mysqlctl.DisableBinlogServerService(binlogServer) }
func main() { dbConfigsFile, dbCredentialsFile := dbconfigs.RegisterCommonFlags() flag.Parse() servenv.Init() defer servenv.Close() tabletAlias := vttablet.TabletParamToTabletAlias(*tabletPath) if *mycnfFile == "" { *mycnfFile = mysqlctl.MycnfFile(tabletAlias.Uid) } mycnf, err := mysqlctl.ReadMycnf(*mycnfFile) if err != nil { log.Fatalf("mycnf read failed: %v", err) } dbcfgs, err := dbconfigs.Init(mycnf.SocketFile, *dbConfigsFile, *dbCredentialsFile) if err != nil { log.Warning(err) } ts.InitQueryService() mysqlctl.RegisterUpdateStreamService(mycnf) // Depends on both query and updateStream. ts.RegisterCacheInvalidator() // Depends on both query and updateStream. if err := vttablet.InitAgent(tabletAlias, dbcfgs, mycnf, *dbConfigsFile, *dbCredentialsFile, *port, *securePort, *mycnfFile, *overridesFile); err != nil { log.Fatal(err) } servenv.ServeRPC() vttablet.HttpHandleSnapshots(mycnf, tabletAlias.Uid) l, err := proc.Listen(fmt.Sprintf("%v", *port)) if err != nil { log.Fatal(err) } go http.Serve(l, nil) if *securePort != 0 { log.Infof("listening on secure port %v", *securePort) vttablet.SecureServe(fmt.Sprintf(":%d", *securePort), *cert, *key, *caCert) } log.Infof("started vttablet %v", *port) s := proc.Wait() // A SIGUSR1 means that we're restarting if s == syscall.SIGUSR1 { // Give some time for the other process // to pick up the listeners log.Info("Exiting on SIGUSR1") time.Sleep(5 * time.Millisecond) ts.DisallowQueries(true) } else { log.Info("Exiting on SIGTERM") ts.DisallowQueries(false) } mysqlctl.DisableUpdateStreamService() topo.CloseServers() vttablet.CloseAgent() }