Example #1
0
func main() {
	flag.Usage = usage
	flag.Parse()
	log.Println("start blobserver service …")

	if *version {
		fmt.Fprintln(os.Stdout, Version)
		return
	}

	if *help {
		flag.Usage()
		os.Exit(1)
	}

	conf, err := config.ReadFile(*configFilename)

	if err != nil {
		log.Fatal(err)
	}

	if conf.Listen == "" && *laddr == "" {
		log.Fatal("Listen address required")
	} else if conf.Listen == "" {
		conf.Listen = *laddr
	}

	runtime.GOMAXPROCS(runtime.NumCPU())

	if *cpuprofile != "" {
		f, err := os.Create(*cpuprofile)
		if err != nil {
			log.Fatal(err)
		}
		pprof.StartCPUProfile(f)
		defer pprof.StopCPUProfile()
	}

	storage, err := blobserver.CreateStorage(conf)

	if err != nil {
		log.Fatalf("error instantiating storage for type %s: %v",
			conf.StorageType(), err)
	}

	log.Printf("Using `%s` storage", conf.StorageType())
	err = server.ListenAndServe(*laddr, storage)

	if err != nil {
		log.Errorln(err)
	}

	monitoring.MeasuringPointsPrintAll()
}
Example #2
0
func TestS3(t *testing.T) {
	configFile := os.Getenv("BLOBSERVER_S3_TEST_CONFIG")
	if configFile == "" {
		t.Skip("Skipping manual test. To enable, set the environment variable BLOBSERVER_S3_TEST_CONFIG to the path of a JSON configuration for the s3 storage type.")
	}
	conf, err := config.ReadFile(configFile)
	if err != nil {
		t.Fatalf("Error reading s3 configuration file %s: %v", configFile, err)
	}
	storagetest.Test(t, func(t *testing.T) (sto blobserver.Storage, cleanup func()) {
		sto, err := newFromConfig(conf)
		if err != nil {
			t.Fatalf("newFromConfig error: %v", err)
		}
		return sto, func() {}
	})
}
Example #3
0
func storageFromConf(t *testing.T) blobserver.Storage {
	configFile := os.Getenv("BLOBSERVER_SWIFT_TEST_CONFIG")
	if configFile == "" {
		t.Skip("Skipping manual test. To enable, set the environment variable BLOBSERVER_SWIFT_TEST_CONFIG to the path of a JSON configuration for the s3 storage type.")
	}
	conf, err := config.ReadFile(configFile)
	if err != nil {
		t.Fatalf("Error reading swift configuration file %s: %v", configFile, err)
	}

	sto, err := newFromConfig(conf)
	if err != nil {
		t.Fatalf("newFromConfig error: %v", err)
	}

	return sto
}