forked from mirror/ledisdb
repo conf command should check replication ok
This commit is contained in:
parent
13767e1bb2
commit
218700ce44
|
@ -157,6 +157,10 @@ func replconfCommand(c *client) error {
|
||||||
return ErrCmdParams
|
return ErrCmdParams
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !c.app.ldb.ReplicationUsed() {
|
||||||
|
return ledis.ErrRplNotSupport
|
||||||
|
}
|
||||||
|
|
||||||
//now only support "listening-port"
|
//now only support "listening-port"
|
||||||
for i := 0; i < len(args); i += 2 {
|
for i := 0; i < len(args); i += 2 {
|
||||||
switch strings.ToLower(hack.String(args[i])) {
|
switch strings.ToLower(hack.String(args[i])) {
|
||||||
|
|
|
@ -76,7 +76,11 @@ func newMaster(app *App) *master {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *master) Close() {
|
func (m *master) Close() {
|
||||||
m.quit <- struct{}{}
|
select {
|
||||||
|
case m.quit <- struct{}{}:
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
m.closeConn()
|
m.closeConn()
|
||||||
|
|
||||||
|
@ -161,7 +165,12 @@ func (m *master) runReplication(restart bool) {
|
||||||
|
|
||||||
if _, err := m.conn.Do("ping"); err != nil {
|
if _, err := m.conn.Do("ping"); err != nil {
|
||||||
log.Errorf("ping master %s error %s, try 3s later", m.addr, err.Error())
|
log.Errorf("ping master %s error %s, try 3s later", m.addr, err.Error())
|
||||||
time.Sleep(3 * time.Second)
|
|
||||||
|
select {
|
||||||
|
case <-time.After(3 * time.Second):
|
||||||
|
case <-m.quit:
|
||||||
|
return
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,7 +181,17 @@ func (m *master) runReplication(restart bool) {
|
||||||
m.state.Set(replConnectedState)
|
m.state.Set(replConnectedState)
|
||||||
|
|
||||||
if err := m.replConf(); err != nil {
|
if err := m.replConf(); err != nil {
|
||||||
|
if strings.Contains(err.Error(), ledis.ErrRplNotSupport.Error()) {
|
||||||
|
log.Fatalf("master doesn't support replication, wait 10s and retry")
|
||||||
|
select {
|
||||||
|
case <-time.After(10 * time.Second):
|
||||||
|
case <-m.quit:
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else {
|
||||||
log.Errorf("replconf error %s", err.Error())
|
log.Errorf("replconf error %s", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue