// TestMain is called from the command line. func TestMain(m *testing.M) { backend := backend.Backend{Implementation: "memory"} flag.Var(&backend, "backend", "impl:address of coordinate storage") flag.Parse() c, err := backend.Coordinate() if err != nil { panic(err) } check.Suite(&PythonSuite{Coordinate: c}) os.Exit(m.Run()) }
func main() { var err error var namespace coordinate.Namespace bind := flag.String("bind", ":5932", "[ip]:port to listen on") backend := backend.Backend{Implementation: "memory", Address: ""} flag.Var(&backend, "backend", "impl[:address] of the storage backend") config := flag.String("config", "", "global configuration YAML file") flag.Parse() var gConfig map[string]interface{} if *config != "" { gConfig, err = loadConfigYaml(*config) if err != nil { panic(err) } } cbor := new(codec.CborHandle) coordinate, err := backend.Coordinate() if err == nil { namespace, err = coordinate.Namespace("") } if err == nil { err = cborrpc.SetExts(cbor) } if err != nil { panic(err) } jobd := &jobserver.JobServer{ Namespace: namespace, GlobalConfig: gConfig, } ln, err := net.Listen("tcp", *bind) if err != nil { fmt.Printf("Could not listen to %v: %v\n", *bind, err) return } for { conn, err := ln.Accept() if err != nil { fmt.Printf("Could not accept connection: %v\n", err) return } go handleConnection(conn, jobd, cbor) } }