本文整理汇总了Golang中github.com/youtube/vitess/go/vt/topo.CloseServers函数的典型用法代码示例。如果您正苦于以下问题:Golang CloseServers函数的具体用法?Golang CloseServers怎么用?Golang CloseServers使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CloseServers函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
defer exit.Recover()
flag.Parse()
servenv.Init()
if initFakeZK != nil {
initFakeZK()
}
ts := topo.GetServer()
defer topo.CloseServers()
resilientSrvTopoServer = vtgate.NewResilientSrvTopoServer(ts, "ResilientSrvTopoServer")
healthCheck = discovery.NewHealthCheck(*connTimeoutTotal, *healthCheckRetryDelay, *healthCheckTimeout, "" /* statsSuffix */)
tabletTypes := make([]topodatapb.TabletType, 0, 1)
if len(*tabletTypesToWait) != 0 {
for _, ttStr := range strings.Split(*tabletTypesToWait, ",") {
tt, err := topoproto.ParseTabletType(ttStr)
if err != nil {
log.Errorf("unknown tablet type: %v", ttStr)
continue
}
tabletTypes = append(tabletTypes, tt)
}
}
vtg := vtgate.Init(context.Background(), healthCheck, ts, resilientSrvTopoServer, *cell, *retryDelay, *retryCount, *connTimeoutTotal, *connTimeoutPerConn, *connLife, tabletTypes, *maxInFlight, *testGateway)
servenv.OnRun(func() {
addStatusParts(vtg)
})
servenv.RunDefault()
}
示例2: main
func main() {
flag.Parse()
args := flag.Args()
installSignalHandlers()
servenv.Init()
defer servenv.Close()
ts := topo.GetServer()
defer topo.CloseServers()
// the logger will be replaced when we start a job
wr = wrangler.New(logutil.NewConsoleLogger(), ts, 30*time.Second, 30*time.Second)
if len(args) == 0 {
// interactive mode, initialize the web UI to chose a command
initInteractiveMode()
} else {
// single command mode, just runs it
runCommand(args)
}
initStatusHandling()
servenv.RunDefault()
}
示例3: main
func main() {
defer exit.Recover()
flag.Parse()
servenv.Init()
ts := topo.GetServer()
defer topo.CloseServers()
resilientSrvTopoServer = vtgate.NewResilientSrvTopoServer(ts, "ResilientSrvTopoServer")
healthCheck = discovery.NewHealthCheck(*healthCheckConnTimeout, *healthCheckRetryDelay, *healthCheckTimeout)
healthCheck.RegisterStats()
tabletTypes := make([]topodatapb.TabletType, 0, 1)
if len(*tabletTypesToWait) != 0 {
for _, ttStr := range strings.Split(*tabletTypesToWait, ",") {
tt, err := topoproto.ParseTabletType(ttStr)
if err != nil {
log.Errorf("unknown tablet type: %v", ttStr)
continue
}
tabletTypes = append(tabletTypes, tt)
}
}
l2vtg := l2vtgate.Init(healthCheck, ts, resilientSrvTopoServer, *cell, *retryCount, tabletTypes)
servenv.OnRun(func() {
addStatusParts(l2vtg)
})
servenv.RunDefault()
}
示例4: main
func main() {
dbConfigsFile, dbCredentialsFile := dbconfigs.RegisterCommonFlags()
flag.Parse()
relog.Info("started vtaction %v", os.Args)
rpc.HandleHTTP()
jsonrpc.ServeHTTP()
jsonrpc.ServeRPC()
bsonrpc.ServeHTTP()
bsonrpc.ServeRPC()
logFile, err := os.OpenFile(*logFilename,
os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0666)
if err != nil {
relog.Fatal("Can't open log file: %v", err)
}
relog.SetOutput(logFile)
relog.SetPrefix(fmt.Sprintf("vtaction [%v] ", os.Getpid()))
if err := relog.SetLevelByName(*logLevel); err != nil {
relog.Fatal("%v", err)
}
relog.HijackLog(nil)
relog.HijackStdio(logFile, logFile)
mycnf, mycnfErr := mysqlctl.ReadMycnf(*mycnfFile)
if mycnfErr != nil {
relog.Fatal("mycnf read failed: %v", mycnfErr)
}
relog.Debug("mycnf: %v", jscfg.ToJson(mycnf))
dbcfgs, cfErr := dbconfigs.Init(mycnf.SocketFile, *dbConfigsFile, *dbCredentialsFile)
if err != nil {
relog.Fatal("%s", cfErr)
}
mysqld := mysqlctl.NewMysqld(mycnf, dbcfgs.Dba, dbcfgs.Repl)
topoServer := topo.GetServer()
defer topo.CloseServers()
actor := tabletmanager.NewTabletActor(mysqld, topoServer)
// we delegate out startup to the micromanagement server so these actions
// will occur after we have obtained our socket.
bindAddr := fmt.Sprintf(":%v", *port)
httpServer := &http.Server{Addr: bindAddr}
go func() {
if err := httpServer.ListenAndServe(); err != nil {
relog.Error("httpServer.ListenAndServe err: %v", err)
}
}()
actionErr := actor.HandleAction(*actionNode, *action, *actionGuid, *force)
if actionErr != nil {
relog.Fatal("action error: %v", actionErr)
}
relog.Info("finished vtaction %v", os.Args)
}
示例5: main
func main() {
defer exit.Recover()
flag.Parse()
servenv.Init()
if initFakeZK != nil {
initFakeZK()
}
ts := topo.GetServer()
defer topo.CloseServers()
var schema *planbuilder.Schema
if *schemaFile != "" {
var err error
if schema, err = planbuilder.LoadFile(*schemaFile); err != nil {
log.Error(err)
exit.Return(1)
}
log.Infof("v3 is enabled: loaded schema from file: %v", *schemaFile)
} else {
ctx := context.Background()
schemaJSON, err := ts.GetVSchema(ctx)
if err != nil {
log.Warningf("Skipping v3 initialization: GetVSchema failed: %v", err)
goto startServer
}
schema, err = planbuilder.NewSchema([]byte(schemaJSON))
if err != nil {
log.Warningf("Skipping v3 initialization: GetVSchema failed: %v", err)
goto startServer
}
log.Infof("v3 is enabled: loaded schema from topo")
}
startServer:
resilientSrvTopoServer = vtgate.NewResilientSrvTopoServer(ts, "ResilientSrvTopoServer")
healthCheck = discovery.NewHealthCheck(*connTimeoutTotal, *healthCheckRetryDelay, *healthCheckTimeout, "" /* statsSuffix */)
tabletTypes := make([]topodatapb.TabletType, 0, 1)
if len(*tabletTypesToWait) != 0 {
for _, ttStr := range strings.Split(*tabletTypesToWait, ",") {
tt, err := topoproto.ParseTabletType(ttStr)
if err != nil {
log.Errorf("unknown tablet type: %v", ttStr)
continue
}
tabletTypes = append(tabletTypes, tt)
}
}
vtg := vtgate.Init(healthCheck, ts, resilientSrvTopoServer, schema, *cell, *retryDelay, *retryCount, *connTimeoutTotal, *connTimeoutPerConn, *connLife, tabletTypes, *maxInFlight, *testGateway)
servenv.OnRun(func() {
addStatusParts(vtg)
})
servenv.RunDefault()
}
示例6: main
func main() {
defer exit.Recover()
// flag parsing
flags := dbconfigs.AppConfig | dbconfigs.DbaConfig |
dbconfigs.FilteredConfig | dbconfigs.ReplConfig
dbconfigs.RegisterFlags(flags)
mysqlctl.RegisterFlags()
flag.Parse()
if len(flag.Args()) > 0 {
flag.Usage()
log.Errorf("vtcombo doesn't take any positional arguments")
exit.Return(1)
}
// register topo server
topo.RegisterServer("fakezk", zktopo.NewServer(fakezk.NewConn()))
ts := topo.GetServerByName("fakezk")
servenv.Init()
// database configs
mycnf, err := mysqlctl.NewMycnfFromFlags(0)
if err != nil {
log.Errorf("mycnf read failed: %v", err)
exit.Return(1)
}
dbcfgs, err := dbconfigs.Init(mycnf.SocketFile, flags)
if err != nil {
log.Warning(err)
}
mysqld := mysqlctl.NewMysqld("Dba", "App", mycnf, &dbcfgs.Dba, &dbcfgs.App.ConnParams, &dbcfgs.Repl)
// tablets configuration and init
binlog.RegisterUpdateStreamService(mycnf)
initTabletMap(ts, *topology, mysqld, dbcfgs, mycnf)
// vtgate configuration and init
resilientSrvTopoServer := vtgate.NewResilientSrvTopoServer(ts, "ResilientSrvTopoServer")
healthCheck := discovery.NewHealthCheck(30*time.Second /*connTimeoutTotal*/, 1*time.Millisecond /*retryDelay*/)
vtgate.Init(healthCheck, ts, resilientSrvTopoServer, nil /*schema*/, cell, 1*time.Millisecond /*retryDelay*/, 2 /*retryCount*/, 30*time.Second /*connTimeoutTotal*/, 10*time.Second /*connTimeoutPerConn*/, 365*24*time.Hour /*connLife*/, 0 /*maxInFlight*/, "" /*testGateway*/)
servenv.OnTerm(func() {
// FIXME(alainjobart) stop vtgate, all tablets
// qsc.DisallowQueries()
// agent.Stop()
})
servenv.OnClose(func() {
// We will still use the topo server during lameduck period
// to update our state, so closing it in OnClose()
topo.CloseServers()
})
servenv.RunDefault()
}
示例7: main
func main() {
flag.Parse()
servenv.Init()
ts := topo.GetServer()
defer topo.CloseServers()
topoReader = NewTopoReader(ts)
topo.RegisterTopoReader(topoReader)
servenv.Run(*port)
}
示例8: main
func main() {
defer exit.RecoverAll()
defer logutil.Flush()
flag.Parse()
args := flag.Args()
if len(args) == 0 {
flag.Usage()
exit.Return(1)
}
action := args[0]
installSignalHandlers()
startMsg := fmt.Sprintf("USER=%v SUDO_USER=%v %v", os.Getenv("USER"), os.Getenv("SUDO_USER"), strings.Join(os.Args, " "))
if syslogger, err := syslog.New(syslog.LOG_INFO, "vtctl "); err == nil {
syslogger.Info(startMsg)
} else {
log.Warningf("cannot connect to syslog: %v", err)
}
topoServer := topo.GetServer()
defer topo.CloseServers()
wr := wrangler.New(logutil.NewConsoleLogger(), topoServer, *waitTime, *lockWaitTimeout)
actionPath, err := vtctl.RunCommand(wr, args)
switch err {
case vtctl.ErrUnknownCommand:
flag.Usage()
exit.Return(1)
case nil:
// keep going
default:
log.Errorf("action failed: %v %v", action, err)
exit.Return(255)
}
if actionPath != "" {
if *noWaitForAction {
fmt.Println(actionPath)
} else {
err := wr.WaitForCompletion(actionPath)
if err != nil {
log.Error(err.Error())
exit.Return(255)
} else {
log.Infof("action completed: %v", actionPath)
}
}
}
}
示例9: main
func main() {
dbconfigs.RegisterFlags()
mysqlctl.RegisterFlags()
flag.Parse()
if len(flag.Args()) > 0 {
flag.Usage()
log.Fatalf("vttablet doesn't take any positional arguments")
}
servenv.Init()
if *tabletPath == "" {
log.Fatalf("tabletPath required")
}
tabletAlias := tabletParamToTabletAlias(*tabletPath)
mycnf, err := mysqlctl.NewMycnfFromFlags(tabletAlias.Uid)
if err != nil {
log.Fatalf("mycnf read failed: %v", err)
}
dbcfgs, err := dbconfigs.Init(mycnf.SocketFile)
if err != nil {
log.Warning(err)
}
dbcfgs.App.EnableRowcache = *enableRowcache
if *tableAclConfig != "" {
tableacl.Init(*tableAclConfig)
}
tabletserver.InitQueryService()
binlog.RegisterUpdateStreamService(mycnf)
// Depends on both query and updateStream.
agent, err = tabletmanager.NewActionAgent(tabletAlias, dbcfgs, mycnf, *servenv.Port, *servenv.SecurePort, *overridesFile)
if err != nil {
log.Fatal(err)
}
tabletmanager.HttpHandleSnapshots(mycnf, tabletAlias.Uid)
servenv.OnTerm(func() {
tabletserver.DisallowQueries()
binlog.DisableUpdateStreamService()
agent.Stop()
})
servenv.OnClose(func() {
// We will still use the topo server during lameduck period
// to update our state, so closing it in OnClose()
topo.CloseServers()
})
servenv.RunDefault()
}
示例10: main
func main() {
defer exit.Recover()
flag.Parse()
servenv.Init()
ts := topo.GetServer()
defer topo.CloseServers()
var schema *planbuilder.Schema
if *schemaFile != "" {
var err error
if schema, err = planbuilder.LoadFile(*schemaFile); err != nil {
log.Error(err)
exit.Return(1)
}
log.Infof("v3 is enabled: loaded schema from file: %v", *schemaFile)
} else {
schemafier, ok := ts.(topo.Schemafier)
if !ok {
log.Infof("Skipping v3 initialization: topo does not suppurt schemafier interface")
goto startServer
}
ctx := context.Background()
schemaJSON, err := schemafier.GetVSchema(ctx)
if err != nil {
log.Warningf("Skipping v3 initialization: GetVSchema failed: %v", err)
goto startServer
}
schema, err = planbuilder.NewSchema([]byte(schemaJSON))
if err != nil {
log.Warningf("Skipping v3 initialization: GetVSchema failed: %v", err)
goto startServer
}
log.Infof("v3 is enabled: loaded schema from topo")
}
startServer:
resilientSrvTopoServer = vtgate.NewResilientSrvTopoServer(ts, "ResilientSrvTopoServer")
// For the initial phase vtgate is exposing
// topoReader api. This will be subsumed by
// vtgate once vtgate's client functions become active.
topoReader = NewTopoReader(resilientSrvTopoServer)
servenv.Register("toporeader", topoReader)
vtgate.Init(resilientSrvTopoServer, schema, *cell, *retryDelay, *retryCount, *connTimeoutTotal, *connTimeoutPerConn, *connLife, *maxInFlight)
servenv.RunDefault()
}
示例11: main
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)
}
示例12: main
func main() {
flag.Parse()
servenv.Init()
defer servenv.Close()
ts = topo.GetServer()
defer topo.CloseServers()
// Init the vtctld core
vtctld.InitVtctld(ts)
// Start schema manager service.
initSchema()
// And run the server.
servenv.RunDefault()
}
示例13: main
func main() {
dbconfigs.RegisterFlags()
flag.Parse()
servenv.Init()
if *tabletPath == "" {
log.Fatalf("tabletPath required")
}
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)
if err != nil {
log.Warning(err)
}
dbcfgs.App.EnableRowcache = *enableRowcache
ts.InitQueryService()
binlog.RegisterUpdateStreamService(mycnf)
// Depends on both query and updateStream.
agent, err = vttablet.InitAgent(tabletAlias, dbcfgs, mycnf, *servenv.Port, *servenv.SecurePort, *overridesFile)
if err != nil {
log.Fatal(err)
}
vttablet.HttpHandleSnapshots(mycnf, tabletAlias.Uid)
servenv.OnClose(func() {
time.Sleep(5 * time.Millisecond)
ts.DisallowQueries()
binlog.DisableUpdateStreamService()
topo.CloseServers()
agent.Stop()
})
servenv.Run()
}
示例14: main
func main() {
flag.Parse()
servenv.Init()
ts := topo.GetServer()
defer topo.CloseServers()
resilientSrvTopoServer = vtgate.NewResilientSrvTopoServer(ts, "ResilientSrvTopoServer")
// For the initial phase vtgate is exposing
// topoReader api. This will be subsumed by
// vtgate once vtgate's client functions become active.
topoReader = NewTopoReader(resilientSrvTopoServer)
servenv.Register("toporeader", topoReader)
vtgate.Init(resilientSrvTopoServer, *cell, *retryDelay, *retryCount, *timeout, *maxInFlight)
servenv.RunDefault()
}
示例15: main
func main() {
defer exit.RecoverAll()
defer logutil.Flush()
flag.Parse()
args := flag.Args()
if len(args) == 0 {
flag.Usage()
exit.Return(1)
}
action := args[0]
startMsg := fmt.Sprintf("USER=%v SUDO_USER=%v %v", os.Getenv("USER"), os.Getenv("SUDO_USER"), strings.Join(os.Args, " "))
if syslogger, err := syslog.New(syslog.LOG_INFO, "vtctl "); err == nil {
syslogger.Info(startMsg)
} else {
log.Warningf("cannot connect to syslog: %v", err)
}
topoServer := topo.GetServer()
defer topo.CloseServers()
ctx, cancel := context.WithTimeout(context.Background(), *waitTime)
wr := wrangler.New(logutil.NewConsoleLogger(), topoServer, tmclient.NewTabletManagerClient(), *lockWaitTimeout)
installSignalHandlers(cancel)
for _, f := range initFuncs {
f()
}
err := vtctl.RunCommand(ctx, wr, args)
cancel()
switch err {
case vtctl.ErrUnknownCommand:
flag.Usage()
exit.Return(1)
case nil:
// keep going
default:
log.Errorf("action failed: %v %v", action, err)
exit.Return(255)
}
}