本文整理汇总了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()
}
示例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))
}
示例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)
}
}
示例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))
}
示例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))
}
示例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"))
}
示例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))
}
示例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))
}
示例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()))
}
}
示例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"))
}
示例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)
}
}
示例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"))
}
示例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"))
}
示例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())
}
示例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"))
}