From e66bddd84cfe1234344d7b9f19e35024c4a2eee2 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Thu, 6 Jun 2019 00:39:08 -0700 Subject: [PATCH] customizable sleep intervals --- weed/command/scaffold.go | 1 + weed/server/master_server.go | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/weed/command/scaffold.go b/weed/command/scaffold.go index 08efc50eb..062fe0ff8 100644 --- a/weed/command/scaffold.go +++ b/weed/command/scaffold.go @@ -334,6 +334,7 @@ scripts = """ ec.balance -force volume.balance -force """ +sleep_minutes = 17 # sleep minutes between each script execution ` ) diff --git a/weed/server/master_server.go b/weed/server/master_server.go index 0076ed1f1..95f4218de 100644 --- a/weed/server/master_server.go +++ b/weed/server/master_server.go @@ -169,6 +169,8 @@ func (ms *MasterServer) proxyToLeader(f func(w http.ResponseWriter, r *http.Requ func (ms *MasterServer) startAdminScripts() { v := viper.GetViper() adminScripts := v.GetString("master.maintenance.scripts") + v.SetDefault("master.maintenance.sleep_minutes", 17) + sleepMinutes := v.GetInt("master.maintenance.sleep_minutes") glog.V(0).Infof("adminScripts:\n%v", adminScripts) if adminScripts == "" { @@ -195,7 +197,7 @@ func (ms *MasterServer) startAdminScripts() { go func() { commandEnv.MasterClient.WaitUntilConnected() - c := time.Tick(17 * time.Minute) + c := time.Tick(time.Duration(sleepMinutes) * time.Minute) for _ = range c { if ms.Topo.IsLeader() { for _, line := range scriptLines {