本文整理汇总了Golang中github.com/youtube/vitess/go/vt/mysqlctl.NewMycnf函数的典型用法代码示例。如果您正苦于以下问题:Golang NewMycnf函数的具体用法?Golang NewMycnf怎么用?Golang NewMycnf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewMycnf函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
defer exit.Recover()
defer logutil.Flush()
dbconfigs.RegisterFlags()
flag.Parse()
mycnf := mysqlctl.NewMycnf(uint32(*tabletUid), *mysqlPort)
if *mysqlSocket != "" {
mycnf.SocketFile = *mysqlSocket
}
dbcfgs, err := dbconfigs.Init(mycnf.SocketFile)
if err != nil {
log.Errorf("%v", err)
exit.Return(255)
}
mysqld = mysqlctl.NewMysqld("Dba", mycnf, &dbcfgs.Dba, &dbcfgs.Repl)
// Register OnTerm handler before mysqld starts, so we get notified if mysqld
// dies on its own without us (or our RPC client) telling it to.
mysqldTerminated := make(chan struct{})
mysqld.OnTerm(func() {
close(mysqldTerminated)
})
// Start or Init mysqld as needed.
if _, err = os.Stat(mycnf.DataDir); os.IsNotExist(err) {
log.Infof("mysql data dir (%s) doesn't exist, initializing", mycnf.DataDir)
mysqld.Init(*waitTime, *bootstrapArchive, *skipSchema)
} else {
log.Infof("mysql data dir (%s) already exists, starting without init", mycnf.DataDir)
mysqld.Start(*waitTime)
}
servenv.Init()
defer servenv.Close()
// Take mysqld down with us on SIGTERM before entering lame duck.
servenv.OnTerm(func() {
log.Infof("mysqlctl received SIGTERM, shutting down mysqld first")
mysqld.Shutdown(false, 0)
})
// Start RPC server and wait for SIGTERM.
mysqlctldTerminated := make(chan struct{})
go func() {
servenv.RunDefault()
close(mysqlctldTerminated)
}()
select {
case <-mysqldTerminated:
log.Infof("mysqld shut down on its own, exiting mysqlctld")
case <-mysqlctldTerminated:
log.Infof("mysqlctld shut down gracefully")
}
}
开发者ID:plobsing,项目名称:vitess,代码行数:58,代码来源:mysqlctld.go
示例2: newMysqld
func (util *testUtils) newMysqld(dbconfigs *dbconfigs.DBConfigs) mysqlctl.MysqlDaemon {
return mysqlctl.NewMysqld(
"",
"",
mysqlctl.NewMycnf(0, 6802),
&dbconfigs.Dba,
&dbconfigs.App.ConnParams,
&dbconfigs.Repl,
)
}
开发者ID:e4x,项目名称:vitess,代码行数:10,代码来源:testutils_test.go
示例3: main
func main() {
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage: %s [global parameters] command [command parameters]\n", os.Args[0])
fmt.Fprintf(os.Stderr, "\nThe global optional parameters are:\n")
flag.PrintDefaults()
fmt.Fprintf(os.Stderr, "\nThe commands are listed below. Use '%s <command> -h' for more help.\n\n", os.Args[0])
for _, cmd := range commands {
fmt.Fprintf(os.Stderr, " %s", cmd.name)
if cmd.params != "" {
fmt.Fprintf(os.Stderr, " %s", cmd.params)
}
fmt.Fprintf(os.Stderr, "\n")
}
fmt.Fprintf(os.Stderr, "\n")
}
dbConfigsFile, dbCredentialsFile := dbconfigs.RegisterCommonFlags()
flag.Parse()
if err := relog.SetLevelByName(*logLevel); err != nil {
relog.Fatal("%v", err)
}
tabletAddr = fmt.Sprintf("%v:%v", "localhost", *port)
mycnf := mysqlctl.NewMycnf(uint32(*tabletUid), *mysqlPort, mysqlctl.VtReplParams{})
if *mysqlSocket != "" {
mycnf.SocketFile = *mysqlSocket
}
dbcfgs, err := dbconfigs.Init(mycnf.SocketFile, *dbConfigsFile, *dbCredentialsFile)
if err != nil {
relog.Fatal("%v", err)
}
mysqld := mysqlctl.NewMysqld(mycnf, dbcfgs.Dba, dbcfgs.Repl)
action := flag.Arg(0)
for _, cmd := range commands {
if cmd.name == action {
subFlags := flag.NewFlagSet(action, flag.ExitOnError)
subFlags.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage: %s %s %s\n\n", os.Args[0], cmd.name, cmd.params)
fmt.Fprintf(os.Stderr, "%s\n\n", cmd.help)
subFlags.PrintDefaults()
}
cmd.method(mysqld, subFlags, flag.Args()[1:])
return
}
}
relog.Fatal("invalid action: %v", action)
}
开发者ID:Eric-Chen,项目名称:vitess,代码行数:53,代码来源:mysqlctl.go
示例4: main
func main() {
defer logutil.Flush()
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage: %s [global parameters] command [command parameters]\n", os.Args[0])
fmt.Fprintf(os.Stderr, "\nThe global optional parameters are:\n")
flag.PrintDefaults()
fmt.Fprintf(os.Stderr, "\nThe commands are listed below. Use '%s <command> -h' for more help.\n\n", os.Args[0])
for _, cmd := range commands {
fmt.Fprintf(os.Stderr, " %s", cmd.name)
if cmd.params != "" {
fmt.Fprintf(os.Stderr, " %s", cmd.params)
}
fmt.Fprintf(os.Stderr, "\n")
}
fmt.Fprintf(os.Stderr, "\n")
}
dbconfigs.RegisterFlags()
flag.Parse()
tabletAddr = fmt.Sprintf("%v:%v", "localhost", *port)
mycnf := mysqlctl.NewMycnf(uint32(*tabletUid), *mysqlPort)
if *mysqlSocket != "" {
mycnf.SocketFile = *mysqlSocket
}
dbcfgs, err := dbconfigs.Init(mycnf.SocketFile)
if err != nil {
log.Fatalf("%v", err)
}
mysqld := mysqlctl.NewMysqld("Dba", mycnf, &dbcfgs.Dba, &dbcfgs.Repl)
defer mysqld.Close()
action := flag.Arg(0)
for _, cmd := range commands {
if cmd.name == action {
subFlags := flag.NewFlagSet(action, flag.ExitOnError)
subFlags.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage: %s %s %s\n\n", os.Args[0], cmd.name, cmd.params)
fmt.Fprintf(os.Stderr, "%s\n\n", cmd.help)
subFlags.PrintDefaults()
}
cmd.method(mysqld, subFlags, flag.Args()[1:])
return
}
}
log.Fatalf("invalid action: %v", action)
}
开发者ID:chinna1986,项目名称:vitess,代码行数:52,代码来源:mysqlctl.go
示例5: newMysqld
func (util *testUtils) newMysqld(dbconfigs *dbconfigs.DBConfigs) mysqlctl.MysqlDaemon {
cnf := mysqlctl.NewMycnf(11111, 6802)
// Assigning ServerID to be different from tablet UID to make sure that there are no
// assumptions in the code that those IDs are the same.
cnf.ServerID = 22222
return mysqlctl.NewMysqld(
cnf,
&dbconfigs.Dba,
&dbconfigs.AllPrivs,
&dbconfigs.App,
&dbconfigs.Repl,
false, /* enablePublishStats */
)
}
开发者ID:dumbunny,项目名称:vitess,代码行数:14,代码来源:testutils_test.go
示例6: newMysqld
func (util *testUtils) newMysqld(dbconfigs *dbconfigs.DBConfigs) mysqlctl.MysqlDaemon {
cnf := mysqlctl.NewMycnf(11111, 6802)
// Assigning ServerID to be different from tablet UID to make sure that there are no
// assumptions in the code that those IDs are the same.
cnf.ServerID = 22222
return mysqlctl.NewMysqld(
"",
"",
cnf,
&dbconfigs.Dba,
&dbconfigs.App.ConnParams,
&dbconfigs.Repl,
)
}
开发者ID:jmptrader,项目名称:vitess,代码行数:14,代码来源:testutils_test.go
示例7: main
func main() {
defer exit.Recover()
defer logutil.Flush()
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage: %s [global parameters] command [command parameters]\n", os.Args[0])
fmt.Fprintf(os.Stderr, "\nThe global optional parameters are:\n")
flag.PrintDefaults()
fmt.Fprintf(os.Stderr, "\nThe commands are listed below. Use '%s <command> -h' for more help.\n\n", os.Args[0])
for _, cmd := range commands {
fmt.Fprintf(os.Stderr, " %s", cmd.name)
if cmd.params != "" {
fmt.Fprintf(os.Stderr, " %s", cmd.params)
}
fmt.Fprintf(os.Stderr, "\n")
}
fmt.Fprintf(os.Stderr, "\n")
}
flags := dbconfigs.AppConfig | dbconfigs.DbaConfig |
dbconfigs.FilteredConfig | dbconfigs.ReplConfig
dbconfigs.RegisterFlags(flags)
flag.Parse()
tabletAddr = netutil.JoinHostPort("localhost", int32(*port))
mycnf := mysqlctl.NewMycnf(uint32(*tabletUID), int32(*mysqlPort))
if *mysqlSocket != "" {
mycnf.SocketFile = *mysqlSocket
}
dbcfgs, err := dbconfigs.Init(mycnf.SocketFile, flags)
if err != nil {
log.Errorf("%v", err)
exit.Return(1)
}
mysqld := mysqlctl.NewMysqld("Dba", "App", mycnf, &dbcfgs.Dba, &dbcfgs.App.ConnParams, &dbcfgs.Repl)
defer mysqld.Close()
action := flag.Arg(0)
for _, cmd := range commands {
if cmd.name == action {
subFlags := flag.NewFlagSet(action, flag.ExitOnError)
subFlags.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage: %s %s %s\n\n", os.Args[0], cmd.name, cmd.params)
fmt.Fprintf(os.Stderr, "%s\n\n", cmd.help)
subFlags.PrintDefaults()
}
if err := cmd.method(mysqld, subFlags, flag.Args()[1:]); err != nil {
log.Error(err)
exit.Return(1)
}
return
}
}
log.Errorf("invalid action: %v", action)
exit.Return(1)
}
开发者ID:richarwu,项目名称:vitess,代码行数:61,代码来源:mysqlctl.go
示例8: main
func main() {
defer exit.Recover()
defer logutil.Flush()
flags := dbconfigs.AppConfig | dbconfigs.DbaConfig |
dbconfigs.FilteredConfig | dbconfigs.ReplConfig
dbconfigs.RegisterFlags(flags)
flag.Parse()
mycnf := mysqlctl.NewMycnf(uint32(*tabletUID), int32(*mysqlPort))
if *mysqlSocket != "" {
mycnf.SocketFile = *mysqlSocket
}
dbcfgs, err := dbconfigs.Init(mycnf.SocketFile, flags)
if err != nil {
log.Errorf("%v", err)
exit.Return(255)
}
mysqld = mysqlctl.NewMysqld("Dba", "App", mycnf, &dbcfgs.Dba, &dbcfgs.App.ConnParams, &dbcfgs.Repl)
// Register OnTerm handler before mysqld starts, so we get notified if mysqld
// dies on its own without us (or our RPC client) telling it to.
mysqldTerminated := make(chan struct{})
mysqld.OnTerm(func() {
close(mysqldTerminated)
})
// Start or Init mysqld as needed.
ctx, cancel := context.WithTimeout(context.Background(), *waitTime)
if _, err = os.Stat(mycnf.DataDir); os.IsNotExist(err) {
log.Infof("mysql data dir (%s) doesn't exist, initializing", mycnf.DataDir)
mysqld.Init(ctx, *initDBSQLFile)
} else {
log.Infof("mysql data dir (%s) already exists, starting without init", mycnf.DataDir)
mysqld.Start(ctx)
}
cancel()
servenv.Init()
defer servenv.Close()
// Take mysqld down with us on SIGTERM before entering lame duck.
servenv.OnTerm(func() {
log.Infof("mysqlctl received SIGTERM, shutting down mysqld first")
ctx := context.Background()
mysqld.Shutdown(ctx, false)
})
// Start RPC server and wait for SIGTERM.
mysqlctldTerminated := make(chan struct{})
go func() {
servenv.RunDefault()
close(mysqlctldTerminated)
}()
select {
case <-mysqldTerminated:
log.Infof("mysqld shut down on its own, exiting mysqlctld")
case <-mysqlctldTerminated:
log.Infof("mysqlctld shut down gracefully")
}
}
开发者ID:littleyang,项目名称:vitess,代码行数:63,代码来源:mysqlctld.go
注:本文中的github.com/youtube/vitess/go/vt/mysqlctl.NewMycnf函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论