當前位置: 首頁>>代碼示例>>Golang>>正文


Golang volume.NewHandler函數代碼示例

本文整理匯總了Golang中github.com/docker/go-plugins-helpers/volume.NewHandler函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewHandler函數的具體用法?Golang NewHandler怎麽用?Golang NewHandler使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了NewHandler函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: main

func main() {
	// Set up channel on which to send signal notifications.
	// We must use a buffered channel or risk missing the signal
	// if we're not ready to receive when the signal is sent.
	sigs := make(chan os.Signal, 1)
	signal.Notify(sigs, os.Interrupt, os.Kill)

	// var Usage = func() {
	// 	fmt.Fprintf(os.Stderr, "Usage %s [options]\n", os.Args[0])
	// 	flag.PrintDefaults()
	// }

	flag.Parse()

	_, err := os.Lstat(*ipfsMountPoint)
	if err != nil {
		fmt.Fprintf(os.Stderr, "%v\n%s does not exists, can't start..\n Please use ipfs command line to mount it\n", err, *ipfsMountPoint)
		os.Exit(1)
	}

	d := newIPFSDriver(*ipfsMountPoint)
	h := volume.NewHandler(d)
	go func() {
		if err := h.ServeUnix("root", "ipfs"); err != nil {
			fmt.Println(err)
		}
	}()
	cmd := startIPFSDaemon()
	cmd.Wait()
}
開發者ID:ChristianKniep,項目名稱:docker-volume-ipfs,代碼行數:30,代碼來源:main.go

示例2: main

func main() {
	var Usage = func() {
		fmt.Fprintf(os.Stderr, "Usage: %s [options] url\n", os.Args[0])
		flag.PrintDefaults()
	}

	flag.Parse()
	if flag.NArg() != 1 {
		Usage()
		os.Exit(1)
	}

	config := keywhizConfig{
		ServerURL:      flag.Args()[0],
		CertFile:       *certFile,
		KeyFile:        *keyFile,
		CaFile:         *caFile,
		User:           *user,
		Group:          *group,
		Ping:           *ping,
		Debug:          *debug,
		TimeoutSeconds: time.Duration(*timeoutSeconds) * time.Second,
	}

	lockMemory(config.Debug)

	d := newKeywhizDriver(*root, config)
	h := volume.NewHandler(d)
	fmt.Printf("Listening on %s\n", socketAddress)
	fmt.Println(h.ServeUnix("root", socketAddress))
}
開發者ID:arthurtsang,項目名稱:docker-volume-keywhiz,代碼行數:31,代碼來源:main.go

示例3: main

func main() {
	flag.Var(&flAddrs, "addr", "List of address to KV store")
	flag.Parse()

	if len(flAddrs) == 0 {
		logrus.Fatal("need at least one addr to connect to kv store")
	}

	if *flDebug {
		logrus.SetLevel(logrus.DebugLevel)
	}

	if _, err := os.Stat(*flHome); err != nil {
		if !os.IsNotExist(err) {
			logrus.Fatal(err)
		}
		logrus.Debugf("created home dir at %s", *flHome)
		if err := os.MkdirAll(*flHome, 0700); err != nil {
			logrus.Fatal(err)
		}
	}

	kvfs := newDriver(*flStore, *flHome, flAddrs.GetAll())

	signal.Trap(func() {
		kvfs.cleanup()
	})

	h := volume.NewHandler(kvfs)
	if err := h.ServeUnix("root", *flListen); err != nil {
		logrus.Fatal(err)
	}
}
開發者ID:cpuguy83,項目名稱:docker-kvfs-driver,代碼行數:33,代碼來源:main.go

示例4: main

func main() {
	quobyteMountPath := flag.String("path", "/run/docker/quobyte/mnt", "Path where Quobyte is mounted on the host")
	quobyteMountOptions := flag.String("options", "-o user_xattr", "Fuse options to be used when Quobyte is mounted")

	quobyteUser := flag.String("user", "root", "User to connect to the Quobyte API server")
	quobytePassword := flag.String("password", "quobyte", "Password for the user to connect to the Quobyte API server")
	quobyteAPIURL := flag.String("api", "localhost:7860", "URL to the API server(s) in the form host[:port][,host:port] or SRV record name")
	quobyteRegistry := flag.String("registry", "localhost:7861", "URL to the registry server(s) in the form of host[:port][,host:port] or SRV record name")

	group := flag.String("group", "root", "Group to create the unix socket")
	showVersion := flag.Bool("version", false, "Shows version string")
	flag.Parse()

	if *showVersion {
		log.Printf("Version: %s - Revision: %s\n", version, revision)
		return
	}

	if err := os.MkdirAll(*quobyteMountPath, 0555); err != nil {
		log.Println(err.Error())
	}

	if !isMounted(*quobyteMountPath) {
		log.Printf("Mounting Quobyte namespace in %s", *quobyteMountPath)
		mountAll(*quobyteMountOptions, *quobyteRegistry, *quobyteMountPath)
	}

	qDriver := newQuobyteDriver(*quobyteAPIURL, *quobyteUser, *quobytePassword, *quobyteMountPath)
	handler := volume.NewHandler(qDriver)
	log.Println(handler.ServeUnix(*group, quobyteID))
}
開發者ID:quobyte,項目名稱:docker-volume,代碼行數:31,代碼來源:main.go

示例5: main

func main() {
	flag.Parse()

	d := newSshfsDriver(*root)
	h := volume.NewHandler(d)
	fmt.Printf("listening on %s\n", socketAddress)
	fmt.Println(h.ServeUnix("root", socketAddress))
}
開發者ID:steff1193,項目名稱:docker-volume-sshfs,代碼行數:8,代碼來源:main.go

示例6: Start

func Start(cfgFile string, debug bool) {
	if debug == true {
		log.SetLevel(log.DebugLevel)
	} else {
		log.SetLevel(log.InfoLevel)
	}
	d := New(cfgFile)
	h := volume.NewHandler(d)
	log.Info(h.ServeUnix("root", "solidfire"))
}
開發者ID:coolsvap,項目名稱:solidfire-docker-driver,代碼行數:10,代碼來源:daemon.go

示例7: main

func main() {
	debug := os.Getenv("DEBUG")
	if ok, _ := strconv.ParseBool(debug); ok {
		logrus.SetLevel(logrus.DebugLevel)
	}

	d := newSshfsDriver(filepath.Join("/mnt", sshfsID))
	h := volume.NewHandler(d)
	logrus.Infof("listening on %s", socketAddress)
	logrus.Error(h.ServeUnix("", socketAddress))
}
開發者ID:vieux,項目名稱:docker-volume-sshfs,代碼行數:11,代碼來源:main.go

示例8: main

func main() {

	// Request handler with a driver implementation
	log.Printf("[Init] INFO volume root is %s\n", *volRoot)
	d := initDriver(*volRoot, *defPool, *defFsType, *defSize)
	h := dkvolume.NewHandler(&d)

	// Listen for requests in a unix socket:
	log.Printf("[Init] INFO listening on %s\n", socket)
	fmt.Println(h.ServeUnix("", socket))
}
開發者ID:h0tbird,項目名稱:docker-volume-rbd,代碼行數:11,代碼來源:main.go

示例9: start

func start(dt drivers.DriverType, driver volume.Driver) {
	h := volume.NewHandler(driver)
	if isTCPEnabled() {
		addr := os.Getenv(EnvTCPAddr)
		if addr == "" {
			addr, _ = rootCmd.PersistentFlags().GetString(PortFlag)
		}
		fmt.Println(h.ServeTCP(dt.String(), addr, nil))
	} else {
		fmt.Println(h.ServeUnix("", dt.String()))
	}
}
開發者ID:ContainX,項目名稱:docker-volume-netshare,代碼行數:12,代碼來源:netshare.go

示例10: docker

func docker(cmd *cobra.Command, args []string) {
	config := driver.DriverConfig{
		Consistency: viper.GetString("consistency"),
		Keyspace:    viper.GetString("keyspace"),
		Server:      viper.GetString("server"),
		StateDir:    viper.GetString("statedir"),
		VolumeDir:   viper.GetString("voldir"),
	}
	driver := driver.NewCassFsDriver(&config)
	if driver == nil {
		panic("Got nil back for driver")
	}
	handler := volume.NewHandler(driver)
	fmt.Println(handler.ServeUnix("root", "cassfs"))
}
開發者ID:cgt212,項目名稱:cassfs,代碼行數:15,代碼來源:docker.go

示例11: main

func main() {
	flag.Parse()

	if *help {
		usage(0)
	}

	// Fill in the default volume options
	var opts volumeOptions

	if err := opts.setSize(*size); err != nil {
		logrus.Fatalf(err.Error())
	}
	if err := opts.setMode(*mode); err != nil {
		logrus.Fatalf(err.Error())
	}
	if err := opts.setCLog(*clog); err != nil {
		logrus.Fatalf(err.Error())
	}
	if err := opts.setTier(*tier); err != nil {
		logrus.Fatalf(err.Error())
	}

	// Set log level
	if *debug {
		if *quiet {
			logrus.Fatalf("Flags 'debug' and 'quiet' are mutually exclusive")
		}
		logrus.SetLevel(logrus.DebugLevel)
		ploop.SetVerboseLevel(ploop.Timestamps)
		logrus.Debugf("Debug logging enabled")
	}
	if *quiet {
		logrus.SetOutput(os.Stderr)
		logrus.SetLevel(logrus.ErrorLevel)
		ploop.SetVerboseLevel(ploop.NoStdout)
	}

	// Let's run!
	d := newPloopDriver(*home, &opts)
	h := volume.NewHandler(d)
	e := h.ServeUnix("root", "ploop")
	if e != nil {
		logrus.Fatalf("Failed to initialize: %s", e)
	}
}
開發者ID:kolyshkin,項目名稱:docker-volume-ploop,代碼行數:46,代碼來源:main.go

示例12: main

func main() {
	var Usage = func() {
		fmt.Fprintf(os.Stderr, "Usage: %s [options]\n", os.Args[0])
		flag.PrintDefaults()
	}

	flag.Parse()
	if len(*serversList) == 0 {
		Usage()
		os.Exit(1)
	}

	servers := strings.Split(*serversList, ":")

	d := newGlusterfsDriver(*root, *restAddress, *gfsBase, servers)
	h := volume.NewHandler(d)
	fmt.Println(h.ServeUnix("root", "glusterfs"))
}
開發者ID:swaroopkundeti,項目名稱:docker-volume-glusterfs,代碼行數:18,代碼來源:main.go

示例13: main

func main() {
	var Usage = func() {
		fmt.Fprintf(os.Stderr, "Usage: %s [options]\n", os.Args[0])
		flag.PrintDefaults()
	}

	flag.Parse()
	if *url == "" || *token == "" {
		Usage()
		os.Exit(1)
	}

	lockMemory()

	vault.DefaultConfig = &api.Config{Address: *url, HttpClient: http.DefaultClient}
	d := newDriver(*root, *token)
	h := volume.NewHandler(d)
	fmt.Println(h.ServeUnix("root", "vault"))
}
開發者ID:calavera,項目名稱:docker-volume-vault,代碼行數:19,代碼來源:main.go

示例14: TestMain

func TestMain(m *testing.M) {
	flag.Parse()
	cephConf := os.Getenv("CEPH_CONF")

	testDriver = newCephRBDVolumeDriver(
		"test",
		"",
		"admin",
		"rbd",
		dkvolume.DefaultDockerRootDirectory,
		cephConf,
		false,
	)
	defer testDriver.shutdown()

	handler := dkvolume.NewHandler(testDriver)
	// Serve won't return so spin off routine
	go handler.ServeUnix("", TEST_SOCKET_PATH)

	os.Exit(m.Run())
}
開發者ID:porcupie,項目名稱:rbd-docker-plugin,代碼行數:21,代碼來源:driver_test.go

示例15: main

func main() {
	showVersion := flag.Bool("version", false, "Display version number of plugin and exit")
	flag.Parse()
	if *showVersion == true {
		fmt.Println("Version: ", VERSION)
		os.Exit(0)
	}

	cfgFile := flag.String("config", "/var/lib/cinder/dockerdriver/config.json", "path to config file")
	debug := flag.Bool("debug", true, "enable debug logging")
	flag.Parse()
	if *debug == true {
		log.SetLevel(log.DebugLevel)
	} else {
		log.SetLevel(log.InfoLevel)
	}
	log.Info("Starting cinder-docker-driver version: ", VERSION)
	d := New(*cfgFile)
	h := volume.NewHandler(d)
	log.Info(h.ServeUnix("root", "cinder"))
}
開發者ID:j-griffith,項目名稱:cinder-docker-driver,代碼行數:21,代碼來源:main.go


注:本文中的github.com/docker/go-plugins-helpers/volume.NewHandler函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。