Ejemplo n.º 1
0
func init() {
	flag.StringVar(&options.CPUProfile, "cpuprofile", "", "write cpu profile to file")
	flag.Uint64Var(&options.SpoolSize, "spool-size", 1024,
		"Maximum number of events to spool before a flush is forced.")
	flag.IntVar(&options.NumWorkers, "num-workers", 1,
		"deprecated option, strictly for backwards compatibility. does nothing.")
	flag.DurationVar(&options.IdleTimeout, "idle-flush-time", 5*time.Second,
		"Maximum time to wait for a full spool before flushing anyway")
	flag.StringVar(&options.ConfigFile, "config", "", "The config file to load")
	flag.StringVar(&options.LogFile, "log-file", "", "Log file output")
	flag.StringVar(&options.PidFile, "pid-file", "lumberjack.pid",
		"destination to which a pidfile will be written")
	flag.BoolVar(&options.UseSyslog, "log-to-syslog", false,
		"Log to syslog instead of stdout. This option overrides the --log-file option.")
	flag.BoolVar(&options.FromBeginning, "from-beginning", false,
		"Read new files from the beginning, instead of the end")
	flag.StringVar(&options.HistoryPath, "progress-file", ".lumberjack",
		"path of file used to store progress data")
	flag.StringVar(&options.TempDir, "temp-dir", "/tmp",
		"directory for creating temp files")
	flag.IntVar(&options.NumThreads, "threads", 1, "Number of OS threads to use")
	flag.IntVar(&options.CmdPort, "cmd-port", 42586, "tcp command port number")
	flag.StringVar(&options.HttpPort, "http", "",
		"http port for debug info. No http server is run if this is left off. E.g.: http=:6060")
}
Ejemplo n.º 2
0
func initFlags() {

	certPath := filepath.Join(os.Getenv("DOCKER_CERT_PATH"))
	if certPath == "" {
		certPath = filepath.Join(os.Getenv("HOME"), ".docker")
	}
	flag.BoolVar(&version, "version", false, "show version")
	flag.BoolVar(&watch, "watch", false, "watch for container changes")
	flag.BoolVar(&onlyExposed, "only-exposed", false, "only include containers with exposed ports")

	flag.BoolVar(&onlyPublished, "only-published", false,
		"only include containers with published ports (implies -only-exposed)")
	flag.StringVar(&notifyCmd, "notify", "", "run command after template is regenerated (e.g `restart xyz`)")
	flag.StringVar(&notifySigHUPContainerID, "notify-sighup", "",
		"send HUP signal to container.  Equivalent to `docker kill -s HUP container-ID`")
	flag.Var(&configFiles, "config", "config files with template directives. Config files will be merged if this option is specified multiple times.")
	flag.IntVar(&interval, "interval", 0, "notify command interval (secs)")
	flag.StringVar(&endpoint, "endpoint", "", "docker api endpoint (tcp|unix://..). Default unix:///var/run/docker.sock")
	flag.StringVar(&tlsCert, "tlscert", filepath.Join(certPath, "cert.pem"), "path to TLS client certificate file")
	flag.StringVar(&tlsKey, "tlskey", filepath.Join(certPath, "key.pem"), "path to TLS client key file")
	flag.StringVar(&tlsCaCert, "tlscacert", filepath.Join(certPath, "ca.pem"), "path to TLS CA certificate file")
	flag.BoolVar(&tlsVerify, "tlsverify", os.Getenv("DOCKER_TLS_VERIFY") != "", "verify docker daemon's TLS certicate")

	flag.Usage = usage
	flag.Parse()
}
Ejemplo n.º 3
0
func main() {
	var bindAddress string
	var port int

	flag.IntVar(&port, "port", 9125, "Port to listen on")
	flag.IntVar(&port, "p", 9125, "Port to listen on")

	flag.StringVar(&bindAddress, "bind", "0.0.0.0", "IP Address to listen on")
	flag.StringVar(&bindAddress, "b", "0.0.0.0", "IP Address to listen on")

	flag.StringVar(&prefix, "prefix", "statsrelay", "The prefix to use with self generated stats")

	flag.BoolVar(&verbose, "verbose", false, "Verbose output")
	flag.BoolVar(&verbose, "v", false, "Verbose output")

	flag.Parse()

	if len(flag.Args()) == 0 {
		log.Fatalf("One or most host specifications are needed to locate statsd daemons.\n")
	}

	hashRing = consistent.New()
	hashRing.NumberOfReplicas = 1

	for _, v := range flag.Args() {
		var addr *net.UDPAddr
		var err error
		host := strings.Split(v, ":")

		switch len(host) {
		case 1:
			log.Printf("Invalid statsd location: %s\n", v)
			log.Fatalf("Must be of the form HOST:PORT or HOST:PORT:INSTANCE\n")
		case 2:
			addr, err = net.ResolveUDPAddr("udp", v)
			if err != nil {
				log.Printf("Error parsing HOST:PORT \"%s\"\n", v)
				log.Fatalf("%s\n", err.Error())
			}
		case 3:
			addr, err = net.ResolveUDPAddr("udp", host[0]+":"+host[1])
			if err != nil {
				log.Printf("Error parsing HOST:PORT:INSTANCE \"%s\"\n", v)
				log.Fatalf("%s\n", err.Error())
			}
		default:
			log.Fatalf("Unrecongnized host specification: %s\n", v)
		}

		if addr != nil {
			udpAddr[v] = addr
			hashRing.Add(v)
		}
	}

	epochTime = time.Now().Unix()
	runServer(bindAddress, port)

	log.Printf("Normal shutdown.\n")
}
Ejemplo n.º 4
0
func (c *cover) setOptions() {
	flag.BoolVar(&c.set, "cover", false, "Use the cover tool.")
	flag.BoolVar(&c.open, "open", true,
		"Open the results of the cover tool on the browser.")
	flag.Float64Var(&c.threshold,
		"threshold", defaultThreshold, "The accepted code coverage threshold.")
}
Ejemplo n.º 5
0
Archivo: ucat.go Proyecto: rht/ipget
func parseArgs() args {
	var a args

	// setup + parse flags
	flag.BoolVar(&a.listen, "listen", false, "listen for connections")
	flag.BoolVar(&a.listen, "l", false, "listen for connections (short)")
	flag.BoolVar(&a.verbose, "v", false, "verbose debugging")
	flag.Usage = Usage
	flag.Parse()
	osArgs := flag.Args()

	if len(osArgs) < 1 {
		exit("")
	}

	if a.listen {
		a.localAddr = osArgs[0]
	} else {
		if len(osArgs) > 1 {
			a.localAddr = osArgs[0]
			a.remoteAddr = osArgs[1]
		} else {
			a.remoteAddr = osArgs[0]
		}
	}

	return a
}
Ejemplo n.º 6
0
func parseFlags() error {
	flag.BoolVar(&flagA, "a", flagA, "see 'go build' help")
	flag.BoolVar(&flagX, "x", flagX, "see 'go build' help")
	flag.BoolVar(&flagRace, "race", flagRace, "see 'go build' help")
	flag.StringVar(&flagTags, "tags", flagTags, "see 'go build' help")

	flag.BoolVar(&flagV, "v", flagV, "see 'go test' help")
	flag.IntVar(&flagCount, "count", flagCount, "see 'go test' help")
	flag.StringVar(&flagCPU, "cpu", flagCPU, "see 'go test' help")
	flag.StringVar(&flagParallel, "parallel", flagParallel, "see 'go test' help")
	flag.StringVar(&flagRun, "run", flagRun, "see 'go test' help")
	flag.BoolVar(&flagShort, "short", flagShort, "see 'go test' help")
	flag.StringVar(&flagTimeout, "timeout", flagTimeout, "see 'go test' help")
	flag.StringVar(&flagCoverMode, "covermode", flagCoverMode, "see 'go test' help")
	flag.StringVar(&flagCoverProfile, "coverprofile", flagCoverProfile, "see 'go test' help")

	flag.IntVar(&flagParallelPackages, "parallelpackages", flagParallelPackages, "Number of package test run in parallel")

	flag.Parse()
	if flagCoverProfile == "" {
		flagCoverProfile = "out.coverprofile"
	}
	if flagParallelPackages < 1 {
		return fmt.Errorf("flag parallelpackages must be greater than or equal to 1")
	}
	return nil
}
Ejemplo n.º 7
0
func init() {
	flag.StringVar(&configFile, "c", "config.json", "the config file")
	flag.BoolVar(&version, "V", false, "show version")
	flag.BoolVar(&testMode, "t", false, "test config")
	flag.IntVar(&statPort, "s", -1, "set stat server port")
	flag.IntVar(&commitInterval, "i", 10, "set stat server port")
}
Ejemplo n.º 8
0
func main() {
	var quiet bool
	var dontResolveSymlinks bool

	flag.BoolVar(&quiet, "q", false, "warnings will not be printed")
	flag.BoolVar(&dontResolveSymlinks, "s", false, "do not resolve symlink")

	flag.Parse()

	for _, path := range flag.Args() {
		s, err := filepath.Abs(path)
		if err != nil {
			if !quiet {
				fmt.Fprintln(os.Stderr, err)
			}
			continue
		}
		if !dontResolveSymlinks {
			s, err = filepath.EvalSymlinks(s)
			if err != nil {
				if !quiet {
					fmt.Fprintln(os.Stderr, err)
				}
				continue
			}
		}
		fmt.Println(s)
	}
}
Ejemplo n.º 9
0
func init() {
	// Read configuration from files
	read_configurations()

	// Now override configuration with command line parameters
	flag.Usage = func() {
		fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0])
		flag.PrintDefaults()
		fmt.Fprintf(os.Stderr, "\n")
		fmt.Fprintf(os.Stderr, "The following configuration files will also be read:")
		fmt.Fprintf(os.Stderr, " (+ if file is present)\n")
		for _, file := range config_files() {
			if _, err := os.Stat(file); os.IsNotExist(err) {
				fmt.Fprintf(os.Stderr, "  - %s\n", file)
			} else {
				fmt.Fprintf(os.Stderr, "  + %s\n", file)
			}
		}
	}
	flag.StringVar(&cfg.Channel, "c", cfg.Channel, "Post input values to specified channel or user.")
	flag.StringVar(&cfg.IconURL, "i", cfg.IconURL, "This url is used as icon for posting.")
	flag.StringVar(&cfg.Language, "l", cfg.Language, "Specify the language used for syntax highlighting (ruby/python/...)")
	flag.StringVar(&cfg.MatterURL, "m", cfg.MatterURL, "Mattermost incoming webhooks URL.")
	flag.StringVar(&cfg.Title, "t", cfg.Title, "This title is added to posts. (not with -n)")
	flag.StringVar(&cfg.Username, "u", cfg.Username, "This username is used for posting.")
	flag.BoolVar(&cfg.Extra, "x", cfg.Extra, "Add extra info (user/hostname/timestamp).")
	flag.BoolVar(&cfg.NoBuffer, "n", cfg.NoBuffer, "Post input values without buffering.")
	flag.BoolVar(&cfg.PlainText, "p", cfg.PlainText, "Don't surround the post with triple backticks.")
	flag.BoolVar(&flagVersion, "version", false, "show version.")

	flag.Parse()
}
Ejemplo n.º 10
0
func main() {
	flag.BoolVar(&fotki.Verbose, "v", false, "Be verbose")
	flag.BoolVar(&fotki.DryRun, "n", false, "Dry-run")
	flag.BoolVar(&fotki.Rescan, "rescan", false, "Rescan valid directories under root")
	flag.BoolVar(&fotki.RemoveOld, "move", false, "Remove the original files")
	scandir := flag.String("scan", "", "The directory to scan")
	rootdir := flag.String("root", "", "The root directory of the album")

	flag.Parse()

	if fotki.Verbose {
		fmt.Println("# scandir=", *scandir)
		fmt.Println("# rootdir=", *rootdir)
	}

	if *scandir == "" {
		fmt.Fprintln(os.Stderr, "scan flag is required")
		os.Exit(1)
	}

	if *rootdir == "" {
		fmt.Fprintln(os.Stderr, "root flag is required")
		os.Exit(1)
	}

	album := fotki.NewAlbum(*rootdir)
	check(album.Scan(*scandir))

	check(album.Relocate())
	album.ShowFailed()
}
Ejemplo n.º 11
0
func init() {
	flag.StringVar(&Options.Zone, "z", "", "zone")
	flag.BoolVar(&Options.ShowVersion, "v", false, "show version and exit")
	flag.BoolVar(&Options.ShowVersion, "version", false, "show version and exit")
	flag.StringVar(&Options.LogFile, "log", "stdout", "log file")
	flag.StringVar(&Options.LogLevel, "level", "debug", "log level")
	flag.IntVar(&Options.LogRotateSize, "logsize", 10<<30, "max unrotated log file size")
	flag.StringVar(&Options.InfluxAddr, "influxaddr", "", "influxdb server addr")
	flag.StringVar(&Options.ManagerType, "man", "dummy", "manager type <dummy|mysql>")
	flag.StringVar(&Options.InfluxDbname, "influxdb", "", "influxdb db name")
	flag.StringVar(&Options.ListenAddr, "addr", ":9065", "monitor http server addr")
	flag.StringVar(&Options.HintedHandoffDir, "hhdirs", "hh", "hinted handoff dirs seperated by comma")
	flag.Parse()

	if Options.ShowVersion {
		fmt.Fprintf(os.Stderr, "%s-%s\n", gafka.Version, gafka.BuildId)
		os.Exit(0)
	}

	if Options.Zone == "" {
		panic("empty zone not allowed")
	}

	golog.SetOutput(ioutil.Discard)
	if Options.LogFile != "stdout" {
		SetupLogging(Options.LogFile, Options.LogLevel, "panic")
	} else {
		SetupLogging(Options.LogFile, Options.LogLevel, "")
	}

	ctx.LoadFromHome()
}
Ejemplo n.º 12
0
func main() {
	flag.BoolVar(&CmdlineOptions.Verbose, "v", false, "Verbose")
	flag.BoolVar(&CmdlineOptions.WaitForEvent, "w", false, "For commands that return an event_id, wait for the event to complete.")
	InitRoutingTable()
	flag.Parse()
	route := FindMatchingRoute(flag.Args())
	if CmdlineOptions.Verbose {
		fmt.Fprintf(os.Stderr, "Args: %s\n", flag.Args())
	}
	if CmdlineOptions.Verbose {
		fmt.Fprintf(os.Stderr, "Route: %s\n", route)
	}

	if route == nil {
		fmt.Fprintf(os.Stderr, "Error: unrecognized command: %s\n", flag.Args())
		ShowGeneralHelp(route)
		os.Exit(1)
	}

	if !InitConfig() {
		fmt.Fprintf(os.Stderr, "Invalid or Missing configuration file.\n")
		os.Exit(1)
	}
	if CmdlineOptions.Verbose {
		fmt.Fprintf(os.Stderr, "Config: %s\n", Config)
	}

	if route != nil {
		if CmdlineOptions.Verbose {
			fmt.Fprintf(os.Stderr, "Calling route: %s\n", route)
		}
		route.Handler(route)
	}
}
Ejemplo n.º 13
0
func main() {
	var pubFile, privFile string
	var help, listen, stayOpen bool
	flag.BoolVar(&help, "h", false, "display a short usage message")
	flag.BoolVar(&stayOpen, "k", false, "keep listening after client disconnects")
	flag.BoolVar(&listen, "l", false, "listen for incoming connections")
	flag.StringVar(&privFile, "s", "", "path to signature key")
	flag.StringVar(&pubFile, "v", "", "path to verification key")
	flag.Parse()

	if help {
		usage()
		os.Exit(1)
	}

	loadID(privFile, pubFile)
	defer func() {
		if idPriv != nil {
			zero(idPriv[:], 0)
		}
	}()

	if listen {
		if flag.NArg() != 1 {
			fmt.Println("A port is required (and should be the only argument) when listening.")
		}
		listener(stayOpen, flag.Arg(0))
		return
	}

	if flag.NArg() != 2 {
		fmt.Println("An address and port are required (and should be the only arguments).")
	}
	sender(flag.Arg(0) + ":" + flag.Arg(1))
}
Ejemplo n.º 14
0
func parseArgs() args {
	var a args

	// setup + parse flags
	flag.BoolVar(&a.listen, "listen", false, "listen for connections")
	flag.BoolVar(&a.listen, "l", false, "listen for connections (short)")
	flag.BoolVar(&a.verbose, "v", true, "verbose")
	flag.BoolVar(&a.debug, "debug", false, "debugging")
	// flag.StringVar(&a.keyfile, "key", "", "private key file")
	flag.IntVar(&a.keybits, "keybits", 2048, "num bits for generating private key")
	flag.Usage = Usage
	flag.Parse()
	osArgs := flag.Args()

	if len(osArgs) < 1 {
		exit("")
	}

	if a.verbose {
		out("verbose on")
	}

	if a.listen {
		a.localAddr = osArgs[0]
	} else {
		if len(osArgs) > 1 {
			a.localAddr = osArgs[0]
			a.remoteAddr = osArgs[1]
		} else {
			a.remoteAddr = osArgs[0]
		}
	}

	return a
}
Ejemplo n.º 15
0
func init() {
	potentialQueues := os.Getenv("WORKER_QUEUES")
	potentialConcurrency := os.Getenv("WORKER_CONCURRENCY")

	concurrency = 25

	if potentialConcurrency != "" {
		tmp, _ := strconv.ParseInt(potentialConcurrency, 10, 32)
		concurrency = int(tmp)
	}

	flag.StringVar(&queuesString, "queues", potentialQueues, "a comma-separated list of Resque queues")
	flag.Float64Var(&intervalFloat, "interval", 5.0, "sleep interval when no jobs are found")
	flag.IntVar(&concurrency, "concurrency", concurrency, "the maximum number of concurrently executing jobs")
	flag.IntVar(&connections, "connections", 2, "the maximum number of connections to the Redis database")

	redisProvider := os.Getenv("REDIS_PROVIDER")
	var redisEnvUri string
	if redisProvider != "" {
		redisEnvUri = os.Getenv(redisProvider)
	} else {
		redisEnvUri = os.Getenv("REDIS_URL")
	}
	if redisEnvUri == "" {
		redisEnvUri = "redis://localhost:6379/"
	}

	flag.StringVar(&uri, "uri", redisEnvUri, "the URI of the Redis server")
	flag.StringVar(&namespace, "namespace", "resque:", "the Redis namespace")
	flag.BoolVar(&exitOnComplete, "exit-on-complete", false, "exit when the queue is empty")
	flag.BoolVar(&useNumber, "use-number", false, "use json.Number instead of float64 when decoding numbers in JSON. will default to true soon")
}
Ejemplo n.º 16
0
func main() {

	// Set up and parse command-line args.
	runtime.GOMAXPROCS(runtime.NumCPU())
	flag.StringVar(&host, "host", "127.0.0.1", "")
	flag.Float64Var(&numSeconds, "num-seconds", 10, "")
	flag.IntVar(&numClients, "num-clients", 1, "")
	flag.IntVar(&numChannels, "num-channels", 50, "")
	flag.IntVar(&messageSize, "message-size", 20, "")
	flag.BoolVar(&useRedis, "redis", false, "")
	flag.BoolVar(&quiet, "quiet", false, "")
	flag.Parse()
	for i := 0; i < numChannels; i++ {
		channels = append(channels, strconv.Itoa(i))
	}

	// Create publisher/subscriber goroutines, pausing to allow
	// publishers to hit full throttle
	RunWorkers(Publisher)
	time.Sleep(1 * time.Second)
	RunWorkers(Subscriber)

	// Consume metrics until --num-seconds has passed, and display
	// the median value.
	metrics := GetMetrics()
	sort.Ints(metrics)
	fmt.Println("Num clients", numClients, "median", metrics[len(metrics)/2], "msg/sec")

}
Ejemplo n.º 17
0
// Main method.
func main() {
	conf := config.New()

	help, version := false, false
	flag.BoolVar(&help, "help", false, "Prints command line options and exit.")
	flag.BoolVar(&version, "version", false, "Prints the etcdsh version and exit.")
	flag.StringVar(&conf.Machine, "machine", conf.Machine, "Connect to this etcd server.")
	flag.StringVar(&conf.PS1, "ps1", conf.PS1, "First prompt format")
	flag.StringVar(&conf.PS2, "ps2", conf.PS2, "Second prompt format")
	flag.BoolVar(&conf.Colors, "colors", conf.Colors, "Use colors in display.")
	flag.Parse()

	if help {
		printHelp()
		os.Exit(0)
	}
	if version {
		printVersion()
		os.Exit(0)
	}

	fmt.Printf("Connecting to %s\n", conf.Machine)
	client := etcd.NewClient([]string{conf.Machine})

	controller := handlers.NewController(conf, client, os.Stdout, os.Stderr, os.Stdin)
	controller.Add(handlers.NewLsHandler(controller))
	controller.Add(handlers.NewSetHandler(controller))
	controller.Add(handlers.NewHelpHandler(controller))
	controller.Add(handlers.NewCdHandler(controller))
	controller.Add(handlers.NewGetHandler(controller))
	os.Exit(controller.Start())
}
Ejemplo n.º 18
0
Archivo: config.go Proyecto: kebot/MEOW
func parseCmdLineConfig() *Config {
	var c Config
	var listenAddr string

	flag.StringVar(&c.RcFile, "rc", "", "config file, defaults to $HOME/.meow/rc on Unix, ./rc.txt on Windows")
	// Specifying listen default value to StringVar would override config file options
	flag.StringVar(&listenAddr, "listen", "", "listen address, disables listen in config")
	flag.IntVar(&c.Core, "core", 2, "number of cores to use")
	flag.StringVar(&c.LogFile, "logFile", "", "write output to file")
	flag.BoolVar(&c.PrintVer, "version", false, "print version")
	flag.BoolVar(&c.EstimateTimeout, "estimate", true, "enable/disable estimate timeout")

	flag.Parse()

	if c.RcFile == "" {
		c.RcFile = getDefaultRcFile()
	} else {
		c.RcFile = expandTilde(c.RcFile)
	}
	if err := isFileExists(c.RcFile); err != nil {
		Fatal("fail to get config file:", err)
	}
	initConfig(c.RcFile)
	initDomainList(config.DirectFile, domainTypeDirect)
	initDomainList(config.ProxyFile, domainTypeProxy)

	if listenAddr != "" {
		configParser{}.ParseListen(listenAddr)
		cmdHasListenAddr = true // must come after parse
	}
	return &c
}
Ejemplo n.º 19
0
func main() {
	flag.Usage = func() {
		fmt.Fprintf(os.Stderr, "Usage: %s [ <project directory> ]\n",
			os.Args[0])
		flag.PrintDefaults()
	}

	var cf config

	flag.StringVar(&cf.projectName, "n", "",
		"base package name for the project, e.g. github.com/user/proj")
	flag.BoolVar(&cf.update, "u", false,
		"update dependency submodules from their remote repos")
	flag.BoolVar(&cf.prune, "p", false,
		"prune unused dependency submodules")

	flag.Parse()

	cf.rootDir = "."
	switch {
	case flag.NArg() == 1:
		cf.rootDir = flag.Arg(1)
	case flag.NArg() > 1:
		flag.Usage()
		os.Exit(2)
	}

	if err := run(&cf); err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}
}
Ejemplo n.º 20
0
func init() {
	flag.StringVar(&dockerURL, "docker", "unix:///var/run/docker.sock", "Connection to Docker.")
	flag.StringVar(&cleanOld, "clean-old", "", "Delete all images older than this. Use units: 'h','m','s'")
	flag.BoolVar(&cleanNone, "clean-none", false, "Delete all untagged images. (<none>:<none>)")
	flag.StringVar(&stopOld, "stop-old", "", "Stop all container stat are running longer then this. Use units: 'h','m','s'")
	flag.BoolVar(&noConfirm, "yes", false, "Do not require confirmation.")
}
Ejemplo n.º 21
0
func (g *Grep) AddFlags() {
	flag.BoolVar(&g.L, "l", false, "list matching files only")
	flag.BoolVar(&g.C, "c", false, "print match counts only")
	flag.BoolVar(&g.N, "n", false, "show line numbers")
	flag.BoolVar(&g.H, "h", false, "omit file names")
	flag.BoolVar(&g.Z, "0", false, "null delimit file names")
}
Ejemplo n.º 22
0
func main() {
	var server, client bool
	flag.StringVar(&remote, "remote", "", "remote server")
	flag.IntVar(&port, "port", 8080, "the listen port")
	flag.BoolVar(&server, "server", false, "tls server mode")
	flag.BoolVar(&client, "client", false, "tls client mode")
	flag.StringVar(&cert, "cert", "", "the certificate file")
	flag.StringVar(&key, "key", "", "the private key")
	iniflags.Parse()

	if remote == "" {
		log.Fatal("please use --remote to special the server")
	}

	if server {
		if cert == "" || key == "" {
			log.Fatal("in server mode, you must special the certificate and private key")
		}
		server_main()
		return
	}

	if client {
		local_main()
		return
	}

	log.Fatal("please use --server or --client to special a work mode")
}
Ejemplo n.º 23
0
func Parse() *Args {
	args := &Args{BootConfig: cluster.BootConfig{}}

	flag.StringVar(&args.BootConfig.User, "user", "ubuntu", "user to run QEMU as")
	flag.StringVar(&args.BootConfig.Kernel, "kernel", "rootfs/vmlinuz", "path to the Linux binary")
	flag.StringVar(&args.BootConfig.Network, "network", "10.52.0.1/24", "the network to use for vms")
	flag.StringVar(&args.BootConfig.NatIface, "nat", "eth0", "the interface to provide NAT to vms")
	flag.StringVar(&args.RootFS, "rootfs", "rootfs/rootfs.img", "filesystem image to use with QEMU")
	flag.StringVar(&args.CLI, "cli", "flynn", "path to flynn-cli binary")
	flag.StringVar(&args.Flynnrc, "flynnrc", "", "path to flynnrc file")
	flag.StringVar(&args.RouterIP, "router-ip", "127.0.0.1", "IP address of the router")
	flag.StringVar(&args.DBPath, "db", "flynn-test.db", "path to BoltDB database to store pending builds")
	flag.StringVar(&args.Backend, "backend", "libvirt-lxc", "the host backend to use")
	flag.StringVar(&args.ListenAddr, "listen", ":443", "runner https listen address")
	flag.StringVar(&args.TLSCert, "tls-cert", "", "TLS certificate")
	flag.StringVar(&args.TLSKey, "tls-key", "", "TLS key")
	flag.StringVar(&args.AssetsDir, "assets", "runner/assets", "path to the runner assets dir")
	flag.StringVar(&args.Run, "run", "", "regular expression selecting which tests and/or suites to run")
	flag.BoolVar(&args.Build, "build", true, "build Flynn")
	flag.BoolVar(&args.Debug, "debug", false, "enable debug output")
	flag.BoolVar(&args.Kill, "kill", true, "kill the cluster after running the tests")
	flag.BoolVar(&args.KeepRootFS, "keep-rootfs", false, "don't remove the rootfs which was built to run the tests")
	flag.Parse()

	return args
}
Ejemplo n.º 24
0
func init() {
	flag.BoolVar(&mainInstance.flags.verbose, "verbose", false, "Add verbose log to stderr")
	flag.StringVar(&mainInstance.flags.verboseFile, "verbosefile", "", "Will verbose log to a filename rather than stderr")
	flag.IntVar(&mainInstance.flags.chunkSize, "chunksize", 250, "size to chunk xargs into")
	flag.StringVar(&mainInstance.flags.filenamePrefix, "filename_prefix", "", "Prefix to append to all generated files")
	flag.BoolVar(&mainInstance.flags.forceAbs, "abs", false, "will force abs paths for ... dirs")
}
Ejemplo n.º 25
0
func main() {
	var (
		showVersion bool
	)
	flag.BoolVar(&showVersion, "v", false, "show version")
	flag.BoolVar(&showVersion, "version", false, "show version")
	flag.Parse()

	if showVersion {
		fmt.Println("version:", version)
		fmt.Println("build:", buildDate)
		checkLatest(version)
		return
	}
	log.Println("stretcher version:", version)
	stretcher.Init()
	err := stretcher.Run()
	if err != nil {
		log.Println(err)
		if os.Getenv("CONSUL_INDEX") != "" {
			// ensure exit 0 when running under `consul watch`
			return
		} else {
			os.Exit(1)
		}
	}
}
Ejemplo n.º 26
0
func parse() params {

	var p params

	flag.BoolVar(&p.showHelp, "help", false, "Show this brief help listing")
	flag.BoolVar(&p.showVersion, "version", false, "Report the version info")
	flag.BoolVar(&p.verbose, "verbose", false, "Show a bit more runtime debugging")
	flag.BoolVar(&p.quiet, "quiet", false, "Exit quietly (and with success) if locked")
	flag.StringVar(&p.lockFilename, "lockfile", "", "File for lock")
	flag.BoolVar(&p.wait, "wait", false, "Wait for lockfile to appear (else exit on lock)")

	flag.IntVar(&p.sleep, "sleep", 2, "Sleep for <T> seconds on each wait loop")
	flag.IntVar(&p.retries, "retries", 5, "Attempts <N> retries in each wait loop")
	flag.IntVar(&p.maxtime, "maxtime", 10, "Wait for at most <T> seconds for a lock, then exit")

	flag.Parse()
	p.commandInfo = flag.Args()

	if p.showHelp || len(p.commandInfo) == 0 {
		showHelp()
		os.Exit(1)
	}

	if p.showVersion {
		showVersion()
		os.Exit(1)
	}

	if p.lockFilename == "" {
		fmt.Println("--lockfile option can't be empty")
		os.Exit(1)
	}

	return p
}
Ejemplo n.º 27
0
func init() {
	flag.BoolVar(&isVerbose, "v", false, "")
	flag.BoolVar(&isVerbose, "verbose", false, "")
	flag.Usage = func() {
		fmt.Println(path.Base(os.Args[0]), "- Print DNSPOD table changes")
		fmt.Println()
		fmt.Println("Options:")
		fmt.Println("    -v, --verbose    Show more output")
		fmt.Println()
		fmt.Println("Source: https://github.com/caiguanhao/dnspodd")
	}
	flag.Parse()

	githubClient = github.NewClient(oauth2.NewClient(oauth2.NoContext, oauth2.StaticTokenSource(
		&oauth2.Token{AccessToken: string(GITHUB_TOKEN)},
	)))

	if PROXY_URL != "" {
		proxy, err := url.Parse(PROXY_URL)
		if err == nil {
			http.DefaultTransport = &http.Transport{
				Proxy: func(req *http.Request) (*url.URL, error) {
					if req.URL.Host == "api.github.com" {
						return proxy, nil
					}
					return nil, nil
				},
			}
		}
	}
}
Ejemplo n.º 28
0
Archivo: main.go Proyecto: fgeller/rad
func main() {
	hd, err := findHomeDir()
	if err != nil {
		log.Fatalf("Couldn't find home dir: %v", err)
	}
	pd := filepath.Join(hd, ".rad", "sad-packs")

	flag.StringVar(&config.packDir, "packdir", pd, "Path where packages will be installed")
	flag.StringVar(&config.sapAddr, "sapaddr", "geller.io:3025", "Addr where sap serves")
	flag.StringVar(&config.addr, "addr", "localhost:3024", "Addr where sad should serve")
	flag.BoolVar(&config.readOnly, "readonly", false, "Whether to allow modifications of installed packs.")
	flag.BoolVar(&config.devMode, "devmode", false, "Whether to run in dev mode.")
	flag.Parse()

	pd, err = filepath.Abs(config.packDir)
	if err != nil {
		log.Fatalf("Can't find absolute path for %v: %v\n", config.packDir, err)
	}
	config.packDir = pd

	setupGlobals()
	loadInstalled()
	registerBuildVersion()
	registerAssets()
	go waitAndOpenUrl("http://" + config.addr)
	serve(config.addr)
}
Ejemplo n.º 29
0
func main() {
	flag.BoolVar(&fake, "n", false, "If true, don't actually do anything")
	flag.BoolVar(&verbose, "v", false, "Provide verbose output")
	flag.Var(&ignorePrefixes, "ignore", "Package prefix to ignore. Can be given multiple times.")
	flag.Parse()

	gopaths := filepath.SplitList(os.Getenv("GOPATH"))
	if len(gopaths) == 0 {
		log.Fatal("GOPATH must be set")
	}
	pkgName := flag.Arg(0)
	if pkgName == "" {
		log.Fatal("need a package name")
	}
	dest := flag.Arg(1)
	if dest == "" {
		log.Fatal("need a destination path")
	}

	ignorePrefixes = append(ignorePrefixes, pkgName)
	ignorePrefixes = append(ignorePrefixes, dest)
	rewrites = make(map[string]string)
	visited = make(map[string]bool)

	err := vendorize(pkgName, chooseGOPATH(gopaths, dest), dest)
	if err != nil {
		log.Fatal(err)
	}
}
Ejemplo n.º 30
0
Archivo: nssh.go Proyecto: Konboi/nssh
func main() {
	var targets strslice
	var showVersion bool
	flag.Var(&targets, "t", "target hostname")
	flag.BoolVar(&addPrefix, "p", false, "add hostname to line prefix")
	flag.BoolVar(&showVersion, "v", false, "show version")
	flag.Parse()
	if showVersion {
		fmt.Println("version:", version)
		return
	}

	command := flag.Args()
	if len(command) < 1 {
		flag.PrintDefaults()
		return
	}
	wg := &sync.WaitGroup{}
	for _, host := range targets {
		wg.Add(1)
		go func(h string) {
			remoteCommand(h, command)
			wg.Done()
		}(host)
	}
	wg.Wait()
}