Browse Source

auto reconnect to mysql when populate data

pull/46/head
yedf2 4 years ago
parent
commit
5a3208962a
  1. 5
      examples/data.go

5
examples/data.go

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"strings" "strings"
"time"
"github.com/yedf/dtm/common" "github.com/yedf/dtm/common"
"github.com/yedf/dtm/dtmcli" "github.com/yedf/dtm/dtmcli"
@ -25,6 +26,10 @@ func RunSQLScript(conf map[string]string, script string, skipDrop bool) {
continue continue
} }
_, err = dtmcli.DBExec(con, s) _, err = dtmcli.DBExec(con, s)
for _, err = dtmcli.DBExec(con, s); err != nil; { // wait for mysql to start
time.Sleep(3 * time.Second)
_, err = dtmcli.DBExec(con, s)
}
dtmcli.FatalIfError(err) dtmcli.FatalIfError(err)
} }
} }

Loading…
Cancel
Save