diff options
| author | Jeff Carr <[email protected]> | 2024-10-15 11:02:34 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-10-15 11:02:34 -0500 |
| commit | 1c77ec7e63355cab48564a9fb49f34f55b5f0b15 (patch) | |
| tree | 8d081863ea226465827f9d266b0e701da216220e /http.go | |
| parent | aa6b142b7c156b8f1925eb4af10b0b371263a129 (diff) | |
start from the command line works
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'http.go')
| -rw-r--r-- | http.go | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -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 } |
