summaryrefslogtreecommitdiff
path: root/http.go
diff options
context:
space:
mode:
Diffstat (limited to 'http.go')
-rw-r--r--http.go48
1 files changed, 5 insertions, 43 deletions
diff --git a/http.go b/http.go
index e998203..6e47c28 100644
--- a/http.go
+++ b/http.go
@@ -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
}