diff options
| author | Jeff Carr <[email protected]> | 2024-10-16 20:43:01 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-10-16 20:43:01 -0500 |
| commit | 142d9ab1cb8bf10f9f4177efdca9a690a44cc6b8 (patch) | |
| tree | 252c8178bc1510def83bbb2b59b6428c9714b3c5 /http.go | |
| parent | 1c77ec7e63355cab48564a9fb49f34f55b5f0b15 (diff) | |
this is such stupid code because I haven't switched to protobuf
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'http.go')
| -rw-r--r-- | http.go | 48 |
1 files changed, 5 insertions, 43 deletions
@@ -2,7 +2,6 @@ package main import ( "fmt" - "math/rand" "net/http" "strings" "time" @@ -86,48 +85,11 @@ func okHandler(w http.ResponseWriter, r *http.Request) { if tmp == "/start" { start := r.URL.Query().Get("start") - log.Info("Handling URL:", tmp, "start droplet", start) - dur := time.Since(me.unstable) // how long has the cluster been stable? - - fmt.Fprintln(w, "should start droplet here", start, shell.FormatDuration(dur)) - if dur < 17*time.Second { - fmt.Fprintln(w, "grid is still to unstable") - return - } - d := findDroplet(start) - if d == nil { - 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) + // log.Warn("Handling URL:", tmp, "start droplet", start) + b, result := Start(start) + log.Warn("Start returned =", b, "result =", result) + fmt.Fprintln(w, "Start() returned", b) + fmt.Fprintln(w, "result:", result) return } |
