|
@ -208,7 +208,6 @@ func (ms *MasterServer) proxyToLeader(f http.HandlerFunc) http.HandlerFunc { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (ms *MasterServer) startAdminScripts() { |
|
|
func (ms *MasterServer) startAdminScripts() { |
|
|
var err error |
|
|
|
|
|
|
|
|
|
|
|
v := util.GetViper() |
|
|
v := util.GetViper() |
|
|
adminScripts := v.GetString("master.maintenance.scripts") |
|
|
adminScripts := v.GetString("master.maintenance.scripts") |
|
@ -220,9 +219,6 @@ func (ms *MasterServer) startAdminScripts() { |
|
|
v.SetDefault("master.maintenance.sleep_minutes", 17) |
|
|
v.SetDefault("master.maintenance.sleep_minutes", 17) |
|
|
sleepMinutes := v.GetInt("master.maintenance.sleep_minutes") |
|
|
sleepMinutes := v.GetInt("master.maintenance.sleep_minutes") |
|
|
|
|
|
|
|
|
v.SetDefault("master.filer.default", "localhost:8888") |
|
|
|
|
|
filerHostPort := v.GetString("master.filer.default") |
|
|
|
|
|
|
|
|
|
|
|
scriptLines := strings.Split(adminScripts, "\n") |
|
|
scriptLines := strings.Split(adminScripts, "\n") |
|
|
if !strings.Contains(adminScripts, "lock") { |
|
|
if !strings.Contains(adminScripts, "lock") { |
|
|
scriptLines = append(append([]string{}, "lock"), scriptLines...) |
|
|
scriptLines = append(append([]string{}, "lock"), scriptLines...) |
|
@ -235,14 +231,9 @@ func (ms *MasterServer) startAdminScripts() { |
|
|
shellOptions.GrpcDialOption = security.LoadClientTLS(v, "grpc.master") |
|
|
shellOptions.GrpcDialOption = security.LoadClientTLS(v, "grpc.master") |
|
|
shellOptions.Masters = &masterAddress |
|
|
shellOptions.Masters = &masterAddress |
|
|
|
|
|
|
|
|
shellOptions.FilerAddress = pb.ServerAddress(filerHostPort) |
|
|
|
|
|
shellOptions.Directory = "/" |
|
|
shellOptions.Directory = "/" |
|
|
if err != nil { |
|
|
|
|
|
glog.V(0).Infof("failed to parse master.filer.default = %s : %v\n", filerHostPort, err) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
commandEnv := shell.NewCommandEnv(shellOptions) |
|
|
|
|
|
|
|
|
commandEnv := shell.NewCommandEnv(&shellOptions) |
|
|
|
|
|
|
|
|
reg, _ := regexp.Compile(`'.*?'|".*?"|\S+`) |
|
|
reg, _ := regexp.Compile(`'.*?'|".*?"|\S+`) |
|
|
|
|
|
|
|
@ -254,6 +245,10 @@ func (ms *MasterServer) startAdminScripts() { |
|
|
for { |
|
|
for { |
|
|
time.Sleep(time.Duration(sleepMinutes) * time.Minute) |
|
|
time.Sleep(time.Duration(sleepMinutes) * time.Minute) |
|
|
if ms.Topo.IsLeader() { |
|
|
if ms.Topo.IsLeader() { |
|
|
|
|
|
shellOptions.FilerAddress = ms.GetOneFiler() |
|
|
|
|
|
if shellOptions.FilerAddress == "" { |
|
|
|
|
|
continue |
|
|
|
|
|
} |
|
|
for _, line := range scriptLines { |
|
|
for _, line := range scriptLines { |
|
|
for _, c := range strings.Split(line, ";") { |
|
|
for _, c := range strings.Split(line, ";") { |
|
|
processEachCmd(reg, c, commandEnv) |
|
|
processEachCmd(reg, c, commandEnv) |
|
|