func doScience(handler http.Handler, payload *config.Payload) {
	startTime := time.Now()
	go func() {
		err := http.ListenAndServe(":8000", handler)
		config.LogAndExitIfErr(err, "server-crashed", nil)
	}()
	files := make(chan string, 10)
	go func() {
		err := getfiles.AddFilesToChan(payload, files)
		config.LogAndExitIfErr(err, "getting-files-failed", nil)
		waitAndExit(startTime, files, payload)
	}()
	for {
		curFile := <-files
		err := gor.RunGor(curFile, payload)
		config.LogAndExitIfErr(err, "gor-failed", nil)
		config.KV.InfoD("progress", logger.M{
			"exp_url":      payload.ExperimentURL,
			"control_url":  payload.ControlURL,
			"load_url":     payload.LoadURL,
			"reqs":         science.Res.Reqs,
			"diffs":        science.Res.Diffs,
			"last_gorfile": curFile,
		})
		if science.Res.Reqs >= payload.Reqs {
			err := logResults(startTime, payload)
			config.LogAndExitIfErr(err, "logging-results-failed", nil)
			os.Exit(0)
		}
	}
}
doScience sends the stored requests to the provided handler
package main
import (
	"encoding/json"
	"fmt"
	"io/ioutil"
	"log"
	"net/http"
	"os"
	"sync"
	"time"
	"github.com/Clever/http-science/config"
	"github.com/Clever/http-science/email"
	"github.com/Clever/http-science/getfiles"
	"github.com/Clever/http-science/gor"
	"github.com/Clever/http-science/science"
	"github.com/Clever/http-science/validate"
	"gopkg.in/Clever/kayvee-go.v3/logger"
	"gopkg.in/Clever/pathio.v3"
)
func main() {
	var err error
	var handler http.Handler
	if len(os.Args) != 2 {
		config.LogAndExitIfErr(fmt.Errorf("Expected 2 args, got %d", len(os.Args)), "incorrect-number-args", os.Args)
	}
	payloadBuffer := []byte(os.Args[1])
	payload := new(config.Payload)
	err = json.Unmarshal(payloadBuffer, payload)
	config.LogAndExitIfErr(err, "unmarshal-payload-failed", string(payloadBuffer))
	payload, err = validate.Payload(payload)
	config.LogAndExitIfErr(err, "invalid-payload", payload)
	switch payload.JobType {
	case "load":
		handler = setupLoad(payload)
	case "correctness":
		handler, err = setupCorrectness(payload)
	}
	config.LogAndExitIfErr(err, "setup-failed", payload)
	doScience(handler, payload)
}
func setupCorrectness(payload *config.Payload) (http.Handler, error) {
	f, err := ioutil.TempFile(os.TempDir(), "")
	if err != nil {
		return nil, err
	}
	science.Res = science.Results{
		Reqs:    0,
		Codes:   map[int]map[int]int{},
		Mutex:   &sync.Mutex{},
		Diffs:   0,
		DiffLog: f,
	}
	handler := science.CorrectnessTest{
		ControlURL:    payload.ControlURL,
		ExperimentURL: payload.ExperimentURL,
	}
	return handler, nil
}
func setupLoad(payload *config.Payload) http.Handler {
	science.Res = science.Results{
		Reqs:  0,
		Mutex: &sync.Mutex{},
	}
	handler := science.LoadTest{
		URL: payload.LoadURL,
	}
	return handler
}