Skip to content

Commit 2d2a495

Browse files
committed
feat: add --with-proxysql flag for single sandbox deployment
1 parent 5402472 commit 2d2a495

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

cmd/single.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,32 @@ func singleSandbox(cmd *cobra.Command, args []string) {
461461
if err != nil {
462462
common.Exitf(1, globals.ErrCreatingSandbox, err)
463463
}
464+
465+
flags := cmd.Flags()
466+
withProxySQL, _ := flags.GetBool("with-proxysql")
467+
if withProxySQL {
468+
// Determine the sandbox directory that was created
469+
origin := args[0]
470+
if args[0] != sd.BasedirName {
471+
origin = sd.BasedirName
472+
}
473+
sandboxDir := path.Join(sd.SandboxDir, defaults.Defaults().SandboxPrefix+common.VersionToName(origin))
474+
if sd.DirName != "" {
475+
sandboxDir = path.Join(sd.SandboxDir, sd.DirName)
476+
}
477+
478+
// Read port info from sandbox description
479+
sbDesc, err := common.ReadSandboxDescription(sandboxDir)
480+
if err != nil {
481+
common.Exitf(1, "could not read sandbox description: %s", err)
482+
}
483+
masterPort := sbDesc.Port[0]
484+
485+
err = sandbox.DeployProxySQLForTopology(sandboxDir, masterPort, nil, 0, "127.0.0.1")
486+
if err != nil {
487+
common.Exitf(1, "ProxySQL deployment failed: %s", err)
488+
}
489+
}
464490
}
465491

466492
var singleCmd = &cobra.Command{
@@ -488,4 +514,5 @@ func init() {
488514
singleCmd.PersistentFlags().Bool(globals.MasterLabel, false, "Make the server replication ready")
489515
singleCmd.PersistentFlags().Int(globals.ServerIdLabel, 0, "Overwrite default server-id")
490516
setPflag(singleCmd, globals.PromptLabel, "", "", globals.PromptValue, "Default prompt for the single client", false)
517+
singleCmd.PersistentFlags().Bool("with-proxysql", false, "Deploy ProxySQL alongside the single sandbox")
491518
}

0 commit comments

Comments
 (0)