// Serve as a single backend. // Listen on addr, using s as underlying storage. func ServeBackSingle(addr string, s Storage, ready chan<- bool) error { back := &BackConfig{ Addr: addr, Store: s, Ready: ready, } return triblab.ServeBack(back) }
func main() { flag.Parse() store.Logging = *verbose rc, e := trib.LoadRC(*frc) noError(e) run := func(i int) { if i > len(rc.Backs) { noError(fmt.Errorf("back-end index out of range: %d", i)) } backConfig := rc.BackConfig(i, store.NewStorage()) if *readyAddr != "" { backConfig.Ready = ready.Chan(*readyAddr, backConfig.Addr) } log.Printf("bin storage back-end serving on %s", backConfig.Addr) noError(triblab.ServeBack(backConfig)) } args := flag.Args() n := 0 if len(args) == 0 { // scan for addresses on this machine for i, b := range rc.Backs { if local.Check(b) { go run(i) n++ } } if n == 0 { log.Fatal("no back-end found for this host") } } else { // scan for indices for the addresses for _, a := range args { i, e := strconv.Atoi(a) noError(e) go run(i) n++ } } if n > 0 { select {} } }