summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile7
-rw-r--r--event.go25
2 files changed, 23 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index 3a4739f..a954867 100644
--- a/Makefile
+++ b/Makefile
@@ -13,6 +13,13 @@ start-all-droplets:
curl --silent http://localhost:8080/start?start=git.wit.org
curl --silent http://localhost:8080/start?start=go.wit.com
curl --silent http://localhost:8080/start?start=rdate.wit.com
+ curl --silent http://localhost:8080/start?start=uptime.wit.com
+ curl --silent http://localhost:8080/start?start=www.wit.com
+ curl --silent http://localhost:8080/start?start=ping.wit.com
+ curl --silent http://localhost:8080/start?start=wekan.wit.com
+ curl --silent http://localhost:8080/start?start=caddy.wit.org
+ curl --silent http://localhost:8080/start?start=immich.wit.org
+ curl --silent http://localhost:8080/start?start=bernacchi
@#curl --silent http://localhost:8080/start?start=jcarr
@# ./virtigo --start jcarr
diff --git a/event.go b/event.go
index 5bc1fdf..8920bdc 100644
--- a/event.go
+++ b/event.go
@@ -25,13 +25,15 @@ func (h *HyperT) RestartDaemon() {
me.killcount += 1
}
+var stableTimeout time.Duration = 43 * time.Second
+
// checks if the cluster is ready and stable
func clusterReady() (bool, string) {
last := time.Since(me.unstable)
- if last > 133*time.Second {
+ if last > stableTimeout {
// the cluster has not been stable for 133 seconds
- log.Warn("clusterReady() is stable for 133s")
- return true, "clusterReady() is stable for 133s"
+ log.Warn("clusterReady() is stable for ", shell.FormatDuration(stableTimeout), " secs")
+ return true, fmt.Sprintln("clusterReady() is stable ", shell.FormatDuration(stableTimeout), " secs")
}
log.Warn("clusterReady() is unstable for", shell.FormatDuration(last))
return false, "clusterReady() is unstable for " + shell.FormatDuration(last)
@@ -74,19 +76,24 @@ func (h *HyperT) Start(d *DropletT) (bool, string) {
func Start(name string) (bool, string) {
var result string
- dur := time.Since(me.unstable) // how long has the cluster been stable?
- result = fmt.Sprintln("should start droplet", name, "here. grid stable for:", shell.FormatDuration(dur))
- if dur < 17*time.Second {
- result += "grid is still too unstable"
- return false, result
- }
d := findDroplet(name)
if d == nil {
result += "can't start unknown droplet"
return false, result
}
+ if d.CurrentState == "ON" {
+ return false, "EVENT start droplet is already ON"
+ }
+
+ dur := time.Since(me.unstable) // how long has the cluster been stable?
+ result = fmt.Sprintln("should start droplet", name, "here. grid stable for:", shell.FormatDuration(dur))
+ if dur < 17*time.Second {
+ result += "grid is still too unstable"
+ return false, result
+ }
+
// make the list of hypervisors that are active and can start new droplets
var pool []*HyperT
for _, h := range me.hypers {