当前位置: 首页>>代码示例>>Golang>>正文


Golang glog.Exitf函数代码示例

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


在下文中一共展示了Exitf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: main

func main() {
	flag.Parse()
	domain, err := tao.LoadDomain(*configPath, []byte(*domainPass))
	if err != nil {
		glog.Exitf("Couldn't load the config path %s: %s\n", *configPath, err)
		return
	}

	sock, err := net.Listen(*network, *addr)
	if err != nil {
		glog.Exit("Couldn't bind socket to address:", err)
		return
	}

	fmt.Println("tcca: accepting connections")
	for {
		conn, err := sock.Accept()
		if err != nil {
			glog.Exitf("Couldn't accept a connection on %s: %s", *addr, err)
			return
		}

		go tao.HandleCARequest(conn, domain.Keys.SigningKey, domain.Guard)
	}
}
开发者ID:kevinawalsh,项目名称:cloudproxy,代码行数:25,代码来源:tcca.go

示例2: ServeOnce

func ServeOnce(c *server.Config, cf string, hd *httpdown.HTTP) (*server.AuthServer, httpdown.Server) {
	glog.Infof("Config from %s (%d users, %d ACL entries)", cf, len(c.Users), len(c.ACL))
	as, err := server.NewAuthServer(c)
	if err != nil {
		glog.Exitf("Failed to create auth server: %s", err)
	}

	hs := &http.Server{
		Addr:    c.Server.ListenAddress,
		Handler: as,
		TLSConfig: &tls.Config{
			NextProtos:   []string{"http/1.1"},
			Certificates: make([]tls.Certificate, 1),
		},
	}

	glog.Infof("Cert file: %s", c.Server.CertFile)
	glog.Infof("Key file : %s", c.Server.KeyFile)
	hs.TLSConfig.Certificates[0], err = tls.LoadX509KeyPair(c.Server.CertFile, c.Server.KeyFile)
	if err != nil {
		glog.Exitf("Failed to load certificate and key: %s", err)
	}

	s, err := hd.ListenAndServe(hs)
	if err != nil {
		glog.Exitf("Failed to set up listener: %s", err)
	}
	glog.Infof("Serving")
	return as, s
}
开发者ID:rhlmhrtr,项目名称:docker_auth,代码行数:30,代码来源:main.go

示例3: main

func main() {
	flag.Usage = func() {
		fmt.Fprintf(os.Stderr, "Usage: %s [FLAG]... [PROFILE_DIR]...\n", os.Args[0])
		fmt.Fprintf(os.Stderr, "Load the AppArmor profiles specified in the PROFILE_DIR directories.\n")
		flag.PrintDefaults()
	}
	flag.Parse()

	dirs = flag.Args()
	if len(dirs) == 0 {
		glog.Errorf("Must specify at least one directory.")
		flag.Usage()
		os.Exit(1)
	}

	// Check that the required parser binary is found.
	if _, err := exec.LookPath(parser); err != nil {
		glog.Exitf("Required binary %s not found in PATH", parser)
	}

	// Check that loaded profiles can be read.
	if _, err := getLoadedProfiles(); err != nil {
		glog.Exitf("Unable to access apparmor profiles: %v", err)
	}

	if *poll < 0 {
		runOnce()
	} else {
		pollForever()
	}
}
开发者ID:spxtr,项目名称:contrib,代码行数:31,代码来源:loader.go

示例4: ServeOnce

func ServeOnce(c *config.Config, cf string, hd *httpdown.HTTP) (*server.AuthServer, httpdown.Server) {
	glog.Infof("Config from %s (%d users, %d ACL static entries)", cf, len(c.Users), len(c.ACL))
	as, ms, err := server.NewAuthServer(c)
	if err != nil {
		glog.Exitf("Failed to create auth server: %s", err)
	}

	var tlsConfig *tls.Config
	if c.Server.CertFile != "" || c.Server.KeyFile != "" {
		// Check for partial configuration.
		if c.Server.CertFile == "" || c.Server.KeyFile == "" {
			glog.Exitf("Failed to load certificate and key: both were not provided")
		}
		tlsConfig = &tls.Config{
			MinVersion:               tls.VersionTLS10,
			PreferServerCipherSuites: true,
			CipherSuites: []uint16{
				tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
				tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
				tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,
				tls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,
				tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,
				tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,
				tls.TLS_RSA_WITH_AES_128_CBC_SHA,
				tls.TLS_RSA_WITH_AES_256_CBC_SHA,
			},
			NextProtos:   []string{"http/1.1"},
			Certificates: make([]tls.Certificate, 1),
		}
		glog.Infof("Cert file: %s", c.Server.CertFile)
		glog.Infof("Key file : %s", c.Server.KeyFile)
		tlsConfig.Certificates[0], err = tls.LoadX509KeyPair(c.Server.CertFile, c.Server.KeyFile)
		if err != nil {
			glog.Exitf("Failed to load certificate and key: %s", err)
		}
	} else {
		glog.Warning("Running without TLS")
	}
	hs := &http.Server{
		Addr:      c.Server.ListenAddress,
		Handler:   as,
		TLSConfig: tlsConfig,
	}

	s, err := hd.ListenAndServe(hs)
	if err != nil {
		glog.Exitf("Failed to set up listener: %s", err)
	}

	ms.RunManagerServer()
	glog.Infof("Serving")
	return as, s
}
开发者ID:lpmoon,项目名称:docker_auth,代码行数:53,代码来源:main.go

示例5: main

func main() {
	flag.Parse()
	log.Infof("Simulating %v clients.", *count)
	for i := 0; i < *count; i++ {
		id := uuid.New()
		log.Infof("client %v with id %v", i, id)

		client, err := doorman.NewWithID(*addr, id, doorman.DialOpts(grpc.WithInsecure()))
		if err != nil {
			log.Exit(err)
		}
		defer client.Close()

		res, err := client.Resource(*resource, *initialCapacity)
		if err != nil {
			log.Exit(err)
		}

		go manipulateCapacity(res, *initialCapacity, id)

		conn, err := grpc.Dial(*target, grpc.WithInsecure())
		if err != nil {
			log.Exitf("did not connect: %v", err)
		}
		defer conn.Close()

		c := pb.NewGreeterClient(conn)
		rl := ratelimiter.NewQPS(res)

		for i := 0; i < *workers; i++ {
			go func() {
				ctx := context.Background()
				for {
					if err := rl.Wait(ctx); err != nil {
						log.Exitf("rl.Wait: %v", err)
					}

					ctx, cancel := context.WithTimeout(ctx, 30*time.Second)
					if _, err := c.SayHello(ctx, &pb.HelloRequest{Name: *resource}); err != nil {
						log.Error(err)
					}
					cancel()
				}
			}()
		}
	}
	http.Handle("/metrics", prometheus.Handler())
	http.ListenAndServe(fmt.Sprintf(":%v", *port), nil)

}
开发者ID:youtube,项目名称:doorman,代码行数:50,代码来源:doorman_client.go

示例6: run

func (d *deadlockDetector) run() {
	for {
		ch := make(chan bool, 1)
		go func() {
			d.lock.Lock()
			d.lock.Unlock()

			ch <- true
		}()
		select {
		case <-time.After(d.maxLockPeriod):
			go func() {
				defer func() {
					// Let's just be extra sure we die, even if Exitf panics
					glog.Errorf("Failed to Exitf for %s, dying anyway", d.name)
					os.Exit(2)
				}()
				glog.Exitf("Deadlock on %s, exiting", d.name)
			}()
		case <-ch:
			glog.V(6).Infof("%s is not deadlocked", d.name)
		}
		time.Sleep(d.maxLockPeriod / 2)
	}
}
开发者ID:robbfoster-taulia,项目名称:kubernetes,代码行数:25,代码来源:deadlock-detector.go

示例7: TestE2eNode

func TestE2eNode(t *testing.T) {
	if *runServicesMode {
		// If run-services-mode is specified, only run services in current process.
		services.RunE2EServices()
		return
	}
	if *systemValidateMode {
		// If system-validate-mode is specified, only run system validation in current process.
		if err := system.Validate(); err != nil {
			glog.Exitf("system validation failed: %v", err)
		}
		return
	}
	// If run-services-mode is not specified, run test.
	rand.Seed(time.Now().UTC().UnixNano())
	RegisterFailHandler(Fail)
	reporters := []Reporter{}
	reportDir := framework.TestContext.ReportDir
	if reportDir != "" {
		// Create the directory if it doesn't already exists
		if err := os.MkdirAll(reportDir, 0755); err != nil {
			glog.Errorf("Failed creating report directory: %v", err)
		} else {
			// Configure a junit reporter to write to the directory
			junitFile := fmt.Sprintf("junit_%s%02d.xml", framework.TestContext.ReportPrefix, config.GinkgoConfig.ParallelNode)
			junitPath := path.Join(reportDir, junitFile)
			reporters = append(reporters, more_reporters.NewJUnitReporter(junitPath))
		}
	}
	RunSpecsWithDefaultAndCustomReporters(t, "E2eNode Suite", reporters)
}
开发者ID:oszi,项目名称:kubernetes,代码行数:31,代码来源:e2e_node_suite_test.go

示例8: main

// The main function sets up the connection to the storage backend for
// aggregated events (e.g. MongoDB) and fires up an HTTPs server which acts as
// an endpoint for docker notifications.
func main() {
	flag.Parse()
	rand.Seed(time.Now().UnixNano())
	glog.CopyStandardLogTo("INFO")

	// Create our application context
	ctx, _ := NewAppContext()

	// Load config file given by first argument
	configFilePath := flag.Arg(0)
	if configFilePath == "" {
		glog.Exit("Config file not specified")
	}
	c, err := LoadConfig(configFilePath)
	if err != nil {
		glog.Exit(err)
	}
	ctx.Config = c

	// Connect to MongoDB
	session, err := createMongoDbSession(c)
	if err != nil {
		glog.Exit(err)
	}
	defer session.Close()
	ctx.Session = session

	// Wait for errors on inserts and updates and for flushing changes to disk
	session.SetSafe(&mgo.Safe{FSync: true})
	collection := ctx.Session.DB(ctx.Config.DialInfo.DialInfo.Database).C(ctx.Config.Collection)

	// The repository structure shall have a uniqe key on the repository's
	// name field
	index := mgo.Index{
		Key:        []string{"repositoryname"},
		Unique:     true,
		DropDups:   true,
		Background: true,
		Sparse:     true,
	}

	if err = collection.EnsureIndex(index); err != nil {
		glog.Exitf("It looks like your mongo database is incosinstent. ",
			"Make sure you have no duplicate entries for repository names.")
	}

	// Setup HTTP endpoint
	var httpConnectionString = ctx.Config.GetEndpointConnectionString()
	glog.Infof("About to listen on \"%s%s\".", httpConnectionString, ctx.Config.Server.Route)

	mux := http.NewServeMux()
	appHandler := &appHandler{ctx: ctx}
	mux.Handle(ctx.Config.Server.Route, appHandler)
	err = http.ListenAndServeTLS(httpConnectionString, ctx.Config.Server.Ssl.Cert, ctx.Config.Server.Ssl.CertKey, mux)
	if err != nil {
		glog.Exit(err)
	}

	glog.Info("Exiting.")
}
开发者ID:kwk,项目名称:docker-registry-event-collector,代码行数:63,代码来源:main.go

示例9: TestE2eNode

func TestE2eNode(t *testing.T) {
	if *runServicesMode {
		// If run-services-mode is specified, only run services in current process.
		services.RunE2EServices()
		return
	}
	if *runKubeletMode {
		// If run-kubelet-mode is specified, only start kubelet.
		services.RunKubelet()
		return
	}
	if *systemValidateMode {
		// If system-validate-mode is specified, only run system validation in current process.
		if framework.TestContext.NodeConformance {
			// Chroot to /rootfs to make system validation can check system
			// as in the root filesystem.
			// TODO(random-liu): Consider to chroot the whole test process to make writing
			// test easier.
			if err := syscall.Chroot(rootfs); err != nil {
				glog.Exitf("chroot %q failed: %v", rootfs, err)
			}
		}
		if err := system.ValidateDefault(); err != nil {
			glog.Exitf("system validation failed: %v", err)
		}
		return
	}
	// If run-services-mode is not specified, run test.
	rand.Seed(time.Now().UTC().UnixNano())
	RegisterFailHandler(Fail)
	reporters := []Reporter{}
	reportDir := framework.TestContext.ReportDir
	if reportDir != "" {
		// Create the directory if it doesn't already exists
		if err := os.MkdirAll(reportDir, 0755); err != nil {
			glog.Errorf("Failed creating report directory: %v", err)
		} else {
			// Configure a junit reporter to write to the directory
			junitFile := fmt.Sprintf("junit_%s%02d.xml", framework.TestContext.ReportPrefix, config.GinkgoConfig.ParallelNode)
			junitPath := path.Join(reportDir, junitFile)
			reporters = append(reporters, morereporters.NewJUnitReporter(junitPath))
		}
	}
	RunSpecsWithDefaultAndCustomReporters(t, "E2eNode Suite", reporters)
}
开发者ID:kubernetes,项目名称:kubernetes,代码行数:45,代码来源:e2e_node_suite_test.go

示例10: init

func init() {
	cmd := &cobra.Command{
		Use:   "cluster",
		Short: "Create cluster",
		Long:  `Creates a k8s cluster.`,
		Run: func(cmd *cobra.Command, args []string) {
			err := createCluster.Run()
			if err != nil {
				glog.Exitf("%v", err)
			}
		},
	}

	createCmd.AddCommand(cmd)

	executableLocation, err := exec.LookPath(os.Args[0])
	if err != nil {
		glog.Fatalf("Cannot determine location of kops tool: %q.  Please report this problem!", os.Args[0])
	}

	modelsBaseDirDefault := path.Join(path.Dir(executableLocation), "models")

	cmd.Flags().BoolVar(&createCluster.DryRun, "dryrun", false, "Don't create cloud resources; just show what would be done")
	cmd.Flags().StringVar(&createCluster.Target, "target", "direct", "Target - direct, terraform")
	//configFile := cmd.Flags().StringVar(&createCluster., "conf", "", "Configuration file to load")
	cmd.Flags().StringVar(&createCluster.ModelsBaseDir, "modeldir", modelsBaseDirDefault, "Source directory where models are stored")
	cmd.Flags().StringVar(&createCluster.Models, "model", "config,proto,cloudup", "Models to apply (separate multiple models with commas)")
	cmd.Flags().StringVar(&createCluster.NodeModel, "nodemodel", "nodeup", "Model to use for node configuration")

	//defaultStateStore := os.Getenv("KOPS_STATE_STORE")
	//cmd.Flags().StringVar(&createCluster.StateStore, "state", defaultStateStore, "Location to use to store configuration state")

	cmd.Flags().StringVar(&createCluster.Cloud, "cloud", "", "Cloud provider to use - gce, aws")

	cmd.Flags().StringVar(&createCluster.Zones, "zones", "", "Zones in which to run the cluster")
	cmd.Flags().StringVar(&createCluster.MasterZones, "master-zones", "", "Zones in which to run masters (must be an odd number)")

	cmd.Flags().StringVar(&createCluster.Project, "project", "", "Project to use (must be set on GCE)")
	//cmd.Flags().StringVar(&createCluster.Name, "name", "", "Name for cluster")
	cmd.Flags().StringVar(&createCluster.KubernetesVersion, "kubernetes-version", "", "Version of kubernetes to run (defaults to latest)")

	cmd.Flags().StringVar(&createCluster.SSHPublicKey, "ssh-public-key", "~/.ssh/id_rsa.pub", "SSH public key to use")

	cmd.Flags().StringVar(&createCluster.NodeSize, "node-size", "", "Set instance size for nodes")

	cmd.Flags().StringVar(&createCluster.MasterSize, "master-size", "", "Set instance size for masters")

	cmd.Flags().StringVar(&createCluster.VPCID, "vpc", "", "Set to use a shared VPC")
	cmd.Flags().StringVar(&createCluster.NetworkCIDR, "network-cidr", "", "Set to override the default network CIDR")

	cmd.Flags().IntVar(&createCluster.NodeCount, "node-count", 0, "Set the number of nodes")

	cmd.Flags().StringVar(&createCluster.Image, "image", "", "Image to use")

	cmd.Flags().StringVar(&createCluster.DNSZone, "dns-zone", "", "DNS hosted zone to use (defaults to last two components of cluster name)")
	cmd.Flags().StringVar(&createCluster.OutDir, "out", "", "Path to write any local output")
}
开发者ID:crohling,项目名称:kops,代码行数:57,代码来源:create_cluster.go

示例11: parseInt

// parseInt parses an integer number from a string. It logs a fatal
// error if the string cannot be converted to a valid integer.
func parseInt(s string) int {
	i, err := strconv.ParseInt(s, 10, 32)

	if err != nil {
		log.Exitf("Cannot convert %v to int: %v", s, err)
	}

	return int(i)
}
开发者ID:youtube,项目名称:doorman,代码行数:11,代码来源:recipe.go

示例12: parseFloat

// parseFloat parses a floating point number from a string. It logs a fatal
// error if the string cannot be converted to a valid floating point number.
func parseFloat(s string) float64 {
	f, err := strconv.ParseFloat(s, 64)

	if err != nil {
		log.Exitf("Cannot convert %v to float64: %v", s, err)
	}

	return f

}
开发者ID:youtube,项目名称:doorman,代码行数:12,代码来源:recipe.go

示例13: parseIP

func parseIP(address string) net.IP {
	addr, err := net.LookupIP(address)
	if err != nil {
		log.Exit(err)
	}
	if len(addr) < 1 {
		log.Exitf("failed to parse IP from address '%v'", address)
	}
	return addr[0]
}
开发者ID:yp-engineering,项目名称:mesos-runonce,代码行数:10,代码来源:main.go

示例14: cfgOpt

// cfgOpt returns the configuration option from the specified section. If the
// option does not exist an empty string is returned.
func cfgOpt(cfg *conf.ConfigFile, section, option string) string {
	if !cfg.HasOption(section, option) {
		return ""
	}
	s, err := cfg.GetString(section, option)
	if err != nil {
		log.Exitf("Failed to get %s for %s: %v", option, section, err)
	}
	return s
}
开发者ID:Cepave,项目名称:lvs-metrics,代码行数:12,代码来源:main.go

示例15: main

func main() {
	flag.Parse()
	rand.Seed(time.Now().UnixNano())
	glog.CopyStandardLogTo("INFO")

	cf := flag.Arg(0)
	if cf == "" {
		glog.Exitf("Config file not specified")
	}
	c, err := server.LoadConfig(cf)
	if err != nil {
		glog.Exitf("Failed to load config: %s", err)
	}
	rs := RestartableServer{
		configFile: cf,
		hd:         &httpdown.HTTP{},
	}
	rs.Serve(c)
}
开发者ID:arloesol,项目名称:docker_auth,代码行数:19,代码来源:main.go


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