Пример #1
0
func main() {
	flag.Parse()
	cmd := "server"
	if flag.NArg() > 0 {
		cmd = flag.Arg(0)
	}
	switch cmd {
	case "dump":
		if *weedDb == "" {
			log.Fatalf("-db is needed to know what to dump!")
		}
		if err := dumpAll(*weedDb); err != nil {
			log.Fatalf("error dumping %s: %s", *weedDb, err)
		}

	default: //server
		s3srv.Debug = true
		s3intf.Debug = true
		var (
			impl s3intf.Storage
			err  error
		)
		if *dir != "" {
			impl = dirS3.NewDirS3(*dir)
		} else if *weed != "" && *weedDb != "" {
			if impl, err = weedS3.NewWeedS3(*weed, *weedDb); err != nil {
				log.Fatalf("cannot create WeedS3(%s, %s): %s", *weed, *weedDb, err)
			}
		} else {
			log.Fatalf("dir OR weed AND db is required!")
		}
		srvc := s3srv.NewService(*hostPort, impl)
		log.Fatal(http.ListenAndServe(*hostPort, srvc))
	}
}
Пример #2
0
func init() {
	s3srv.Debug = Debug
	s3intf.Debug = false
	backers = append(backers, dirS3.NewDirS3("/tmp"))

	for _, b := range backers {
		handlers = append(handlers, s3srv.NewService(serviceHost, b))
	}
}