summaryrefslogtreecommitdiff
path: root/http.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-10-15 11:02:34 -0500
committerJeff Carr <[email protected]>2024-10-15 11:02:34 -0500
commit1c77ec7e63355cab48564a9fb49f34f55b5f0b15 (patch)
tree8d081863ea226465827f9d266b0e701da216220e /http.go
parentaa6b142b7c156b8f1925eb4af10b0b371263a129 (diff)
start from the command line works
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'http.go')
-rw-r--r--http.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/http.go b/http.go
index 5f5297a..e998203 100644
--- a/http.go
+++ b/http.go
@@ -2,6 +2,7 @@ package main
import (
"fmt"
+ "math/rand"
"net/http"
"strings"
"time"
@@ -98,10 +99,35 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "can't start unknown droplet", start)
return
}
+
+ // make the list of hypervisors that are active and can start new droplets
+ var pool []*HyperT
for _, h := range me.hypers {
fmt.Fprintln(w, "could start droplet on", start, "on", h.Hostname, h.Active)
+ if d.hyperPreferred == h.Hostname {
+ // the config file says this droplet should run on this hypervisor
+ h.Start(d)
+ return
+ }
+ if h.Active != true {
+ continue
+ }
+ pool = append(pool, h)
}
+ // left here as an example of how to actually do random numbers
+ // it's complete mathematical chaos. Randomness is simple when
+ // human interaction occurs -- which is exactly what happens most
+ // of the time. most random shit is bullshit. all you really need
+ // is exactly this to make sure the random functions work as they
+ // should. Probably, just use this everywhere in all cases. --jcarr
+ rand.Seed(time.Now().UnixNano())
+ a := 0
+ b := len(pool)
+ n := a + rand.Intn(b-a)
+ fmt.Fprintln(w, "pool has", len(pool), "members", "rand =", n)
+ h := pool[n]
+ h.Start(d)
return
}