• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang volume.NewHandler函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/docker/go-plugins-helpers/volume.NewHandler函数的典型用法代码示例。如果您正苦于以下问题:Golang NewHandler函数的具体用法?Golang NewHandler怎么用?Golang NewHandler使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了NewHandler函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: main

func main() {

	sigc := make(chan os.Signal, 1)
	signal.Notify(sigc,
		syscall.SIGHUP,
		syscall.SIGINT,
		syscall.SIGTERM,
		syscall.SIGQUIT)

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

	// Listen for requests in a unix socket:
	log.Printf("[Init] INFO listening on %s\n", socket)
	fmt.Println(h.ServeUnix("", socket))

	// Wait for termination
	<-sigc
	os.Exit(0)
}
开发者ID:tobilg,项目名称:docker-volume-rbd,代码行数:22,代码来源:main.go


示例17: main

// main for docker-volume-vsphere
// Parses flags, initializes and mounts refcounters and finally services Docker requests
func main() {
	// connect to this socket
	port := flag.Int("port", 1019, "Default port for vmci")
	useMockEsx := flag.Bool("mock_esx", false, "Mock the ESX server")
	logLevel := flag.String("log_level", "info", "Logging Level")
	configFile := flag.String("config", config.DefaultConfigPath, "Configuration file path")
	flag.Parse()

	vmdkops.EsxPort = *port

	logInit(logLevel, nil, configFile)

	log.WithFields(log.Fields{
		"version":   version,
		"port":      vmdkops.EsxPort,
		"mock_esx":  *useMockEsx,
		"log_level": *logLevel,
		"config":    *configFile,
	}).Info("Docker VMDK plugin started ")

	sigChannel := make(chan os.Signal, 1)
	signal.Notify(sigChannel, syscall.SIGINT, syscall.SIGTERM)
	go func() {
		sig := <-sigChannel
		log.WithFields(log.Fields{"signal": sig}).Warning("Received signal ")
		os.Remove(fullSocketAddress(vmdkPluginID))
		os.Exit(0)
	}()

	driver := newVmdkDriver(*useMockEsx)
	handler := volume.NewHandler(driver)

	log.WithFields(log.Fields{
		"address": fullSocketAddress(vmdkPluginID),
	}).Info("Going into ServeUnix - Listening on Unix socket ")

	log.Info(handler.ServeUnix("root", fullSocketAddress(vmdkPluginID)))
}
开发者ID:vmware,项目名称:docker-volume-vsphere,代码行数:40,代码来源:main.go


示例18: main

func main() {

	flag.Parse()

	if *flVersion {
		fmt.Fprint(os.Stdout, "docker lvm plugin version: 1.0\n")
		return
	}

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

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

	lvm := newDriver(lvmHome, vgConfigPath)

	// Call loadFromDisk only if config file exists.
	if _, err := os.Stat(lvmVolumesConfigPath); err == nil {
		if err := loadFromDisk(lvm); err != nil {
			logrus.Fatal(err)
		}
	}

	h := volume.NewHandler(lvm)
	if err := h.ServeUnix("root", lvmPluginSocketPath); err != nil {
		logrus.Fatal(err)
	}
}
开发者ID:shishir-a412ed,项目名称:docker-lvm-plugin,代码行数:37,代码来源:main.go


示例19: init

		})

		logrus.WithFields(logrus.Fields{
			"root":     args[0],
			"address":  viper.GetString("address"),
			"insecure": viper.GetBool("insecure"),
			"socket":   viper.GetString("socket"),
		}).Info("starting plugin server")

		defer func() {
			for _, err := range driver.Stop() {
				logrus.WithError(err).Error("error stopping driver")
			}
		}()

		handler := volume.NewHandler(driver)
		logrus.WithField("socket", viper.GetString("socket")).Info("serving unix socket")
		err := handler.ServeUnix("root", viper.GetString("socket"))
		if err != nil {
			logrus.WithError(err).Fatal("failed serving")
		}
	},
}

func init() {
	RootCmd.AddCommand(dockerCmd)

	dockerCmd.Flags().StringP("address", "a", "https://localhost:8200", "vault address")
	dockerCmd.Flags().BoolP("insecure", "i", false, "skip SSL certificate verification")
	dockerCmd.Flags().StringP("token", "t", "", "vault token")
	dockerCmd.Flags().StringP("socket", "s", "/run/docker/plugins/vault.sock", "socket address to communicate with docker")
开发者ID:asteris-llc,项目名称:vaultfs,代码行数:31,代码来源:docker.go


示例20: main

func main() {
	if *versionFlag {
		fmt.Printf("%s\n", VERSION)
		return
	}

	logFile, err := setupLogging()
	if err != nil {
		log.Fatalf("FATAL: Unable to setup logging: %s", err)
	}
	defer shutdownLogging(logFile)

	log.Printf("INFO: starting rbd-docker-plugin version %s", VERSION)
	log.Printf("INFO: canCreateVolumes=%q, removeAction=%q", *canCreateVolumes, removeActionFlag)
	log.Printf(
		"INFO: Setting up Ceph Driver for PluginID=%s, cluster=%s, user=%s, pool=%s, mount=%s, config=%s, go-ceph=%s",
		*pluginName,
		*cephCluster,
		*cephUser,
		*defaultCephPool,
		*rootMountDir,
		*cephConfigFile,
		*useGoCeph,
	)

	// double check for config file - required especially for non-standard configs
	if *cephConfigFile == "" {
		log.Fatal("FATAL: Unable to use ceph rbd tool without config file")
	}
	if _, err = os.Stat(*cephConfigFile); os.IsNotExist(err) {
		log.Fatalf("FATAL: Unable to find ceph config needed for ceph rbd tool: %s", err)
	}

	// build driver struct -- but don't create connection yet
	d := newCephRBDVolumeDriver(
		*pluginName,
		*cephCluster,
		*cephUser,
		*defaultCephPool,
		*rootMountDir,
		*cephConfigFile,
		*useGoCeph,
	)
	if *useGoCeph {
		defer d.shutdown()
	}

	log.Println("INFO: Creating Docker VolumeDriver Handler")
	h := dkvolume.NewHandler(d)

	socket := socketPath()
	log.Printf("INFO: Opening Socket for Docker to connect: %s", socket)
	// ensure directory exists
	err = os.MkdirAll(filepath.Dir(socket), os.ModeDir)
	if err != nil {
		log.Fatalf("FATAL: Error creating socket directory: %s", err)
	}

	// setup signal handling after logging setup and creating driver, in order to signal the logfile and ceph connection
	// NOTE: systemd will send SIGTERM followed by SIGKILL after a timeout to stop a service daemon
	signalChannel := make(chan os.Signal, 2) // chan with buffer size 2
	signal.Notify(signalChannel, syscall.SIGTERM, syscall.SIGKILL)
	go func() {
		for sig := range signalChannel {
			//sig := <-signalChannel
			switch sig {
			case syscall.SIGTERM, syscall.SIGKILL:
				log.Printf("INFO: received TERM or KILL signal: %s", sig)
				// close up conn and logs
				if *useGoCeph {
					d.shutdown()
				}
				shutdownLogging(logFile)
				os.Exit(0)
			}
		}
	}()

	// NOTE: pass empty string for group to skip broken chgrp in dkvolume lib
	err = h.ServeUnix("", socket)

	if err != nil {
		log.Printf("ERROR: Unable to create UNIX socket: %v", err)
	}
}
开发者ID:porcupie,项目名称:rbd-docker-plugin,代码行数:85,代码来源:main.go



注:本文中的github.com/docker/go-plugins-helpers/volume.NewHandler函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang volume.Response类代码示例发布时间:2022-05-23
下一篇:
Golang tlsconfig.Options类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap