Exemplo n.º 1
0
func init() {
	fileloads = make(map[int64]string)

	flag.Var(&load_opts, "ld", ld_help_str)
	flag.Var(&load_zero, "ldz", ld_help_str)
	flag.Var(&load_file, "ldf", ld_help_str)
}
Exemplo n.º 2
0
func init() {
	flag.Var(&nsqdTCPAddrs, "nsqd-tcp-address", "nsqd TCP address (may be given multiple times)")
	flag.Var(&destNsqdTCPAddrs, "destination-nsqd-tcp-address", "destination nsqd TCP address (may be given multiple times)")
	flag.Var(&lookupdHTTPAddrs, "lookupd-http-address", "lookupd HTTP address (may be given multiple times)")

	flag.Var(&whitelistJSONFields, "whitelist-json-field", "for JSON messages: pass this field (may be given multiple times)")
}
Exemplo n.º 3
0
Arquivo: main.go Projeto: joshix/rkt
func init() {
	flag.BoolVar(&debug, "debug", false, "Run in debug mode")

	// The following flags need to be supported by stage1 according to
	// https://github.com/coreos/rkt/blob/master/Documentation/devel/stage1-implementors-guide.md
	// Most of them are ignored
	// These are ignored, but stage0 always passes them
	flag.Var(&discardNetlist, "net", "Setup networking")
	flag.StringVar(&discardString, "local-config", common.DefaultLocalConfigDir, "Local config path")

	// These are discarded with a warning
	// TODO either implement these, or stop passing them
	flag.Bool("interactive", true, "The pod is interactive (ignored, always true)")
	flag.Var(pkgflag.NewDiscardFlag("mds-token"), "mds-token", "MDS auth token (not implemented)")

	flag.Var(pkgflag.NewDiscardFlag("hostname"), "hostname", "Set hostname (not implemented)")
	flag.Bool("disable-capabilities-restriction", true, "ignored")
	flag.Bool("disable-paths", true, "ignored")
	flag.Bool("disable-seccomp", true, "ignored")

	dnsConfMode = pkgflag.MustNewPairList(map[string][]string{
		"resolv": {"host", "stage0", "none", "default"},
		"hosts":  {"host", "stage0", "default"},
	}, map[string]string{
		"resolv": "default",
		"hosts":  "default",
	})
	flag.Var(dnsConfMode, "dns-conf-mode", "DNS config file modes")

}
Exemplo n.º 4
0
func main() {
	// do the actual parsing
	flag.Var(&listenersFlag, "l", "Which ports to listen on")
	flag.Var(&connectorsFlag, "c", "Which addresses to try to connect to")
	flag.BoolVar(&infoptr, "v", false, "Turn on verbose mode")
	flag.BoolVar(&debugptr, "vv", false, "Turn on extra verbose mode")
	retryPeriod = time.Duration(1000 * (*flag.Float64("rp", 5.0,
		"Retry rate for double connections")))
	connPeriod = time.Duration(1000 * (*flag.Float64("cp", 0.5,
		"Retry rate for double connections, on success")))
	flag.Parse()

	debug("Number of listeners: " + fmt.Sprint(len(listenersFlag)))
	debug("Number of connectors: " + fmt.Sprint(len(connectorsFlag)))
	// check a possibly temporary condition
	if len(listenersFlag)+len(connectorsFlag) != 2 {
		errmsg(1, "Strictly 2 connections allowed")
	}

	if len(listenersFlag) == 1 && len(connectorsFlag) == 1 {
		listenOne(normalizeAddr(listenersFlag[0]),
			normalizeAddr(connectorsFlag[0]))
	}
	if len(listenersFlag) == 2 && len(connectorsFlag) == 0 {
		listenTwo(normalizeAddr(listenersFlag[0]),
			normalizeAddr(listenersFlag[1]))
	}
	if len(listenersFlag) == 0 && len(connectorsFlag) == 2 {
		connectTwo(normalizeAddr(connectorsFlag[0]),
			normalizeAddr(connectorsFlag[1]))
	}
}
Exemplo n.º 5
0
Arquivo: init.go Projeto: joshix/rkt
func init() {
	flag.BoolVar(&debug, "debug", false, "Run in debug mode")
	flag.Var(&netList, "net", "Setup networking")
	flag.BoolVar(&interactive, "interactive", false, "The pod is interactive")
	flag.StringVar(&privateUsers, "private-users", "", "Run within user namespace. Can be set to [=UIDBASE[:NUIDS]]")
	flag.StringVar(&mdsToken, "mds-token", "", "MDS auth token")
	flag.StringVar(&localConfig, "local-config", common.DefaultLocalConfigDir, "Local config path")
	flag.StringVar(&hostname, "hostname", "", "Hostname of the pod")
	flag.BoolVar(&disableCapabilities, "disable-capabilities-restriction", false, "Disable capability restrictions")
	flag.BoolVar(&disablePaths, "disable-paths", false, "Disable paths restrictions")
	flag.BoolVar(&disableSeccomp, "disable-seccomp", false, "Disable seccomp restrictions")
	dnsConfMode = pkgflag.MustNewPairList(map[string][]string{
		"resolv": {"host", "stage0", "none", "default"},
		"hosts":  {"host", "stage0", "default"},
	}, map[string]string{
		"resolv": "default",
		"hosts":  "default",
	})
	flag.Var(dnsConfMode, "dns-conf-mode", "DNS config file modes")
	flag.BoolVar(&mutable, "mutable", false, "Enable mutable operations on this pod, including starting an empty one")

	// this ensures that main runs only on main thread (thread group leader).
	// since namespace ops (unshare, setns) are done for a single thread, we
	// must ensure that the goroutine does not jump from OS thread to thread
	runtime.LockOSThread()

	localhostIP = net.ParseIP("127.0.0.1")
	if localhostIP == nil {
		panic("localhost IP failed to parse")
	}
}
Exemplo n.º 6
0
func init() {
	flag.StringVar(&FlagAddr, "mpi-addr", "", "address of the local running process")
	flag.Var(&FlagAllAddrs, "mpi-alladdr", "addresses of all of the processes as comma separated values")
	flag.Var(&FlagInitTimeout, "mpi-inittimeout", "duration to wait before timeout in init")
	flag.StringVar(&FlagProtocol, "mpi-protocol", "tcp", "communication protocol to use")
	flag.StringVar(&FlagPassword, "mpi-password", "", "value to use for salting the mpi connection")
}
Exemplo n.º 7
0
func parseFlags() *stage1commontypes.RuntimePod {
	rp := stage1commontypes.RuntimePod{}

	flag.BoolVar(&debug, "debug", false, "Run in debug mode")
	flag.BoolVar(&interactive, "interactive", false, "The pod is interactive")
	flag.StringVar(&localConfig, "local-config", common.DefaultLocalConfigDir, "Local config path")

	// These flags are persisted in the PodRuntime
	flag.BoolVar(&rp.Mutable, "mutable", false, "Enable mutable operations on this pod, including starting an empty one")
	flag.Var(&rp.NetList, "net", "Setup networking")
	flag.StringVar(&rp.PrivateUsers, "private-users", "", "Run within user namespace. Can be set to [=UIDBASE[:NUIDS]]")
	flag.StringVar(&rp.MDSToken, "mds-token", "", "MDS auth token")
	flag.StringVar(&rp.Hostname, "hostname", "", "Hostname of the pod")
	flag.BoolVar(&rp.InsecureOptions.DisableCapabilities, "disable-capabilities-restriction", false, "Disable capability restrictions")
	flag.BoolVar(&rp.InsecureOptions.DisablePaths, "disable-paths", false, "Disable paths restrictions")
	flag.BoolVar(&rp.InsecureOptions.DisableSeccomp, "disable-seccomp", false, "Disable seccomp restrictions")
	dnsConfMode := pkgflag.MustNewPairList(map[string][]string{
		"resolv": {"host", "stage0", "none", "default"},
		"hosts":  {"host", "stage0", "default"},
	}, map[string]string{
		"resolv": "default",
		"hosts":  "default",
	})
	flag.Var(dnsConfMode, "dns-conf-mode", "DNS config file modes")

	flag.Parse()

	rp.Debug = debug
	rp.ResolvConfMode = dnsConfMode.Pairs["resolv"]
	rp.EtcHostsMode = dnsConfMode.Pairs["hosts"]

	return &rp
}
Exemplo n.º 8
0
func init() {
	flag.Var(&address, "address", "The IP address on to serve on (set to 0.0.0.0 for all interfaces)")
	flag.Var(&etcdServerList, "etcd_servers", "List of etcd servers to watch (http://ip:port), comma separated. Mutually exclusive with -etcd_config")
	flag.Var(&corsAllowedOriginList, "cors_allowed_origins", "List of allowed origins for CORS, comma separated.  An allowed origin can be a regular expression to support subdomain matching.  If this list is empty CORS will not be enabled.")
	flag.Var(&portalNet, "portal_net", "A CIDR notation IP range from which to assign portal IPs. This must not overlap with any IP ranges assigned to nodes for pods.")
	client.BindKubeletClientConfigFlags(flag.CommandLine, &kubeletConfig)
}
Exemplo n.º 9
0
func init() {
	flag.Var(&skips, "skip", "skip test case")
	flag.Var(&cases, "case", "run test case")
	flag.BoolVar(&Debug, "debug", false, "enter debug mode")

	log.SetFlags(log.Lshortfile | log.LstdFlags)
}
Exemplo n.º 10
0
func init() {
	var (
		configureFile string
		printVersion  bool
	)

	flag.StringVar(&configureFile, "C", "", "configure file")
	flag.Var(&options.ChainNodes, "F", "forward address, can make a forward chain")
	flag.Var(&options.ServeNodes, "L", "listen address, can listen on multiple ports")
	flag.BoolVar(&printVersion, "V", false, "print version")
	flag.Parse()

	if err := loadConfigureFile(configureFile); err != nil {
		glog.Fatal(err)
	}

	if glog.V(5) {
		http2.VerboseLogs = true
	}

	if flag.NFlag() == 0 {
		flag.PrintDefaults()
		return
	}

	if printVersion {
		fmt.Fprintf(os.Stderr, "GOST %s (%s)\n", gost.Version, runtime.Version())
		return
	}
}
Exemplo n.º 11
0
func init() {
	flag.Var(&in, "in", "comma separated pair of BAM files to be processed.")
	flag.StringVar(&ref, "ref", "", "fasta file of the genome to be processed.")
	flag.StringVar(&annot, "annot", "", "file name of a GFF file containing annotations.")
	flag.Var(&classes, "class", "comma separated set of annotation classes to analyse.")
	flag.StringVar(&out, "out", "", "outfile name.")
	flag.BoolVar(&pretty, "pretty", true, "outfile JSON data indented.")
	flag.BoolVar(&denest, "denest", false, "only consider denested reads for support count.")
	flag.IntVar(&minLength, "min", 20, "minimum length read considered.")
	flag.IntVar(&maxLength, "max", 35, "maximum length read considered.")
	flag.IntVar(&minId, "minid", 90, "minimum percentage identity for mapped bases.")
	flag.IntVar(&minQ, "minQ", 20, "minimum per-base sequence quality.")
	flag.IntVar(&filter, "f", 0, "filter on piwi type 0: no filter, 1: primary, 2: secondary.")
	flag.Float64Var(&minAvQ, "minAvQ", 30, "minimum average per-base sequence quality.")
	flag.IntVar(&mapQ, "mapQ", 0, "minimum mapping quality [0, 255).")
	flag.IntVar(&binLength, "bin", 1e7, "bin length.")
	help := flag.Bool("help", false, "output this usage message.")
	flag.Parse()
	mapQb = byte(mapQ)
	if *help {
		flag.Usage()
		os.Exit(0)
	}
	if in[0] == "" || in[1] == "" || out == "" || !annotOK(annot, classes) || mapQ < 0 || mapQ > 254 {
		flag.Usage()
		os.Exit(1)
	}
}
Exemplo n.º 12
0
func main() {
	flag.BoolVar(&fflag, "f", false, "unlink any already existing file, permitting the link to occur")
	flag.BoolVar(&hflag, "h", false, "if the target is a symlink to a directory, do not descend to it")
	flag.BoolVar(&hflag, "n", false, "alias for -h for compatibility")
	flag.BoolVar(&sflag, "s", false, "create a symbolic link")
	flag.Var(symFlag('L'), "L", "when creating a hard link and the source is a symbolic link, link to the fully resolved target of symbolic link")
	flag.Var(symFlag('P'), "P", "when creating a hardlink and the source is a symbolic link, link to the symbolic link itself")
	flag.Usage = usage
	flag.Parse()

	switch flag.NArg() {
	case 0:
		usage()
	case 1:
		ek(ln(flag.Arg(0), ".", true))
	case 2:
		ek(ln(flag.Arg(0), flag.Arg(1), false))
	default:
		sourceDir := flag.Arg(flag.NArg() - 1)
		fi, err := os.Stat(sourceDir)
		ck(err)

		if !fi.IsDir() {
			usage()
		}

		args := flag.Args()
		for _, name := range args[:len(args)-1] {
			ek(ln(name, sourceDir, true))
		}
	}

	os.Exit(status)
}
Exemplo n.º 13
0
// Parses service options from the command line
func parseOptions() (*serviceOptions, error) {
	options := &serviceOptions{}

	flag.StringVar(&options.codePath, "js", "", "Js code path")
	flag.StringVar(&options.backend, "b", "memory", "Backend type e.g. 'cassandra' or 'memory'")
	flag.StringVar(&options.loadBalancer, "lb", "random", "Loadbalancer algo, e.g. 'random'")

	flag.StringVar(&options.host, "h", "localhost", "Host to bind to")
	flag.IntVar(&options.httpPort, "p", 8080, "HTTP port to bind to")

	flag.StringVar(&options.pidPath, "pid", "", "pid file path")

	flag.Var(&options.cassandraServers, "csnode", "Cassandra nodes to connect to")
	flag.StringVar(&options.cassandraKeyspace, "cskeyspace", "", "Cassandra keyspace")

	flag.BoolVar(&options.cassandraCleanup, "cscleanup", false, "Whethere to perform periodic cassandra cleanups")
	flag.Var(&options.cassandraCleanupOptions, "cscleanuptime", "Cassandra cleanup utc time of day in form: HH:MM")

	flag.DurationVar(&options.cleanupPeriod, "logcleanup", time.Duration(24)*time.Hour, "How often should we remove unused golang logs (e.g. 24h, 1h, 7h)")

	flag.StringVar(&options.discovery, "discovery", "disabled", "Discovery Backend e.g. 'disabled', 'rackspace://${USERNAME}:${API_KEY}', or 'etcd")
	flag.Var(&options.etcdEndpoints, "etcd", "Etcd discovery service API endpoints")

	flag.StringVar(&options.sslCertFile, "sslcert", "", "File containing SSL Certificates")
	flag.StringVar(&options.sslKeyFile, "sslkey", "", "File containing SSL Private Key")

	flag.StringVar(&options.metricsOutput, "metrics", "console", "Comma seperated list of where to send metrics.")
	flag.StringVar(&options.cpuProfile, "cpuprofile", "", "Run with CPU Profiling enabled.")

	flag.Parse()

	return options, nil
}
Exemplo n.º 14
0
func init() {
	flag.Var(&Aliases, "D", "Replace text with some other text")
	flag.Var(&Headers, "H", "Request headers")
	flag.StringVar(&fileName, "filename", "", "File containing list of test rules")

	flag.Parse()
}
Exemplo n.º 15
0
func main() {
	templates := templateList{}
	flag.Var(&templates, "t", "Specify template and append optional destination after collons. Format: foo.tmpl:/etc/foo.conf")
	flag.Var(&keepEnvs, "e", fmt.Sprintf("Keep specified environment variables beside %s", strings.Join(keepEnvs, ",")))
	flag.Parse()
	if *root == "" {
		r, err := os.Getwd()
		if err != nil {
			log.Fatal("Not root (-r) specified and couldn't get working directory")
		}
		*root = r
	}
	args := flag.Args()
	if len(args) == 0 {
		log.Fatal("No command provided, exiting")
	}

	if err := templates.Render(*root); err != nil {
		log.Fatal(err)
	}
	path, err := exec.LookPath(args[0])
	if err != nil {
		log.Fatal(err)
	}
	if *keepAllEnvs {
		execEnv = os.Environ()
	} else {
		execEnv = getFilteredEnv(keepEnvs)
	}
	if err := syscall.Exec(path, args, execEnv); err != nil {
		log.Fatal(err)
	}
}
Exemplo n.º 16
0
func init() {

	flag.Var(&postAddrs, "post", "HTTP address to make a POST request to.  data will be in the body (may be given multiple times)")
	flag.Var(&getAddrs, "get", "HTTP address to make a GET request to. '%s' will be printf replaced with data (may be given multiple times)")
	flag.Var(&nsqdTCPAddrs, "nsqd-tcp-address", "nsqd TCP address (may be given multiple times)")
	flag.Var(&lookupdHTTPAddrs, "lookupd-http-address", "lookupd HTTP address (may be given multiple times)")
}
Exemplo n.º 17
0
func main() {
	now := time.Now()
	times[0] = syscall.Timespec{now.Unix(), int64(now.Nanosecond())}

	flag.Var(timeFlag('d'), "d", "parse date and use it instead of current time")
	flag.Var(timeFlag('t'), "t", "parse time and use it instead of current time")
	flag.Var(timeFlag('T'), "T", "parse as number of seconds since epoch")
	flag.Usage = usage
	flag.Parse()
	if flag.NArg() < 1 {
		usage()
	}

	if !*aflag && !*mflag {
		*aflag, *mflag = true, true
	}

	if *ref != "" {
		st, err := stat(*ref)
		ck(err)
		times[0] = st.Atim
		times[1] = st.Mtim
	} else {
		times[1] = times[0]
	}

	for _, name := range flag.Args() {
		touch(name)
	}
	os.Exit(status)
}
Exemplo n.º 18
0
func init() {
	flag.Var(&readerOpts, "reader-opt", "option to passthrough to nsq.Consumer (may be given multiple times)")
	flag.Var(&postAddrs, "post", "HTTP address to make a POST request to.  data will be in the body (may be given multiple times)")
	flag.Var(&getAddrs, "get", "HTTP address to make a GET request to. '%s' will be printf replaced with data (may be given multiple times)")
	flag.Var(&nsqdTCPAddrs, "nsqd-tcp-address", "nsqd TCP address (may be given multiple times)")
	flag.Var(&lookupdHTTPAddrs, "lookupd-http-address", "lookupd HTTP address (may be given multiple times)")
}
Exemplo n.º 19
0
func main() {

	flag.BoolVar(&version, "version", false, "show version")
	flag.Var(&templatesFlag, "template", "Template (/template:/dest). Can be passed multiple times")
	flag.Var(&stdoutTailFlag, "stdout", "Tails a file to stdout. Can be passed multiple times")
	flag.Var(&stderrTailFlag, "stderr", "Tails a file to stderr. Can be passed multiple times")
	flag.StringVar(&delimsFlag, "delims", "", `template tag delimiters. default "{{":"}}" `)

	flag.Parse()

	if version {
		fmt.Println(buildVersion)
		return
	}

	//TODO: Not needed anymore for standalone mode
	//if flag.NArg() == 0 {
	//	log.Fatalln("no command specified")
	//}

	if delimsFlag != "" {
		delims = strings.Split(delimsFlag, ":")
		if len(delims) != 2 {
			log.Fatalf("bad delimiters argument: %s. expected \"left:right\"", delimsFlag)
		}
	}
	for _, t := range templatesFlag {
		parts := strings.Split(t, ":")
		if len(parts) != 2 {
			log.Fatalf("bad template argument: %s. expected \"/template:/dest\"", t)
		}
		
		if flag.Arg(0) == "" {
			log.Println("Standalone mode, no app to start. Only template resolved")
			generateFile(parts[0], parts[1])
		}
		else {
			log.Println("Resolve and Execute")
			generateFile(parts[0], parts[1])
			// Setup context
			ctx, cancel = context.WithCancel(context.Background())
		
			wg.Add(1)
			go runCmd(ctx, cancel, flag.Arg(0), flag.Args()[1:]...)
		
			for _, out := range stdoutTailFlag {
				wg.Add(1)
				go tailFile(ctx, out, os.Stdout)
			}
		
			for _, err := range stderrTailFlag {
				wg.Add(1)
				go tailFile(ctx, err, os.Stderr)
			}
		
			wg.Wait()
		}
	}
}
Exemplo n.º 20
0
func main() {

	flag.BoolVar(&version, "version", false, "show version")
	flag.Var(&templatesFlag, "template", "Template (/template:/dest). Can be passed multiple times")
	flag.Var(&stdoutTailFlag, "stdout", "Tails a file to stdout. Can be passed multiple times")
	flag.Var(&stderrTailFlag, "stderr", "Tails a file to stderr. Can be passed multiple times")
	flag.StringVar(&delimsFlag, "delims", "", `template tag delimiters. default "{{":"}}" `)

	flag.Usage = usage
	flag.Parse()

	if version {
		fmt.Println(buildVersion)
		return
	}

	if flag.NArg() == 0 && flag.NFlag() == 0 {
		usage()
		os.Exit(1)
	}

	if delimsFlag != "" {
		delims = strings.Split(delimsFlag, ":")
		if len(delims) != 2 {
			log.Fatalf("bad delimiters argument: %s. expected \"left:right\"", delimsFlag)
		}
	}
	for _, t := range templatesFlag {
		template, dest := t, ""
		if strings.Contains(t, ":") {
			parts := strings.Split(t, ":")
			if len(parts) != 2 {
				log.Fatalf("bad template argument: %s. expected \"/template:/dest\"", t)
			}
			template, dest = parts[0], parts[1]
		}
		generateFile(template, dest)
	}

	// Setup context
	ctx, cancel = context.WithCancel(context.Background())

	if flag.NArg() > 0 {
		wg.Add(1)
		go runCmd(ctx, cancel, flag.Arg(0), flag.Args()[1:]...)
	}

	for _, out := range stdoutTailFlag {
		wg.Add(1)
		go tailFile(ctx, out, os.Stdout)
	}

	for _, err := range stderrTailFlag {
		wg.Add(1)
		go tailFile(ctx, err, os.Stderr)
	}

	wg.Wait()
}
Exemplo n.º 21
0
// initialize command-line options
func init() {
	flag.Var(&optIncs, "inc", "word(s) to include in passphrase")
	flag.Var(&optLists, "list", "wordlist(s) to use (lower case L)")
	flag.IntVar(&optChars, "chars", optChars, "minimum number of characters")
	flag.IntVar(&optWords, "words", optWords, "minimum number of words")
	flag.BoolVar(&optCamel, "camel", optCamel, "use CamelCase")
	flag.StringVar(&optSep, "sep", optSep, "word separator")
}
Exemplo n.º 22
0
func init() {
	// TODO: remove, deprecated
	flag.Var(&consumerOpts, "reader-opt", "(deprecated) use --consumer-opt")
	flag.Var(&consumerOpts, "consumer-opt", "option to passthrough to nsq.Consumer (may be given multiple times, http://godoc.org/github.com/bitly/go-nsq#Config)")

	flag.Var(&nsqdTCPAddrs, "nsqd-tcp-address", "nsqd TCP address (may be given multiple times)")
	flag.Var(&lookupdHTTPAddrs, "lookupd-http-address", "lookupd HTTP address (may be given multiple times)")
}
Exemplo n.º 23
0
func init() {
	flag.BoolVar(&defaultConfig.Recursive, "r", false, "Watch directories recursively")
	flag.Var(&defaultConfig.IncludePattern, "include", "Process any events whose file name matches file name matches specified regular expression pattern (perl-style)")
	flag.Var(&defaultConfig.ExcludePattern, "exclude", "Do not process any events whose file name matches specified regular expression pattern (perl-style)")
	flag.DurationVar(&defaultConfig.Interval, "i", 100*time.Millisecond, "The interval limit the frequency of the command executions, if equal to 0, there is no limit (time unit: ns/us/ms/s/m/h)")
	flag.Var(&defaultConfig.Events, "e", "Listen for specific event(s) (comma separated list)")
	flag.Var((*stringSet)(&defaultConfig.Commands), "c", "Add arbitrary command (repeatable)")
}
Exemplo n.º 24
0
func init() {
	flag.Var(excludes, "e", "Packages will be excluded.")
	flag.Var(includes, "i", "Packages will be included.")

	pp.ColoringEnabled = false

	logger = log.New(os.Stderr, "", log.Lshortfile|log.LstdFlags)
}
Exemplo n.º 25
0
Arquivo: main.go Projeto: kisielk/uses
func init() {
	flag.Var(&packages, "pkgs", "Comma-separated list of packages to search for functions.")
	flag.Var(&arguments, "args", "Comma-separated list of argument types to match.")
	flag.Var(&returns, "rets", "Comma-separated list of return types to match.")
	flag.BoolVar(&and, "and", false, "Use AND instead of OR for matching functions.")

	flag.Parse()
}
Exemplo n.º 26
0
func init() {
	flag.Var(&readerOpts, "reader-opt", "option to passthrough to nsq.Consumer (may be given multiple times)")
	flag.Var(&nsqdTCPAddrs, "nsqd-tcp-address", "nsqd TCP address (may be given multiple times)")
	flag.Var(&destNsqdTCPAddrs, "destination-nsqd-tcp-address", "destination nsqd TCP address (may be given multiple times)")
	flag.Var(&lookupdHTTPAddrs, "lookupd-http-address", "lookupd HTTP address (may be given multiple times)")

	flag.Var(&whitelistJsonFields, "whitelist-json-field", "for JSON messages: pass this field (may be given multiple times)")
}
Exemplo n.º 27
0
func init() {
	flag.Var(&algorithm, "a", "select the digest algorithm (shorthand)")
	flag.Var(&algorithm, "algorithm", "select the digest algorithm")
	flag.BoolVar(&showVersion, "version", false, "show the version and exit")

	log.SetFlags(0)
	log.SetPrefix(os.Args[0] + ": ")
}
Exemplo n.º 28
0
func processCommandLine() (*UndertakerData, error) {
	var container_excludes_file string
	var image_excludes_file string
	var conserving_deadline_secs int64
	var c_excludes MultiStringOption
	var i_excludes MultiStringOption
	var c_includes MultiStringOption
	var i_includes MultiStringOption

	flag.StringVar(&container_excludes_file, "filecexc", "", "read container excludes from file")
	flag.StringVar(&image_excludes_file, "fileiexc", "", "read image excludes from file")
	flag.Int64Var(&conserving_deadline_secs, "wait", int64(3600), "conserving deadline in seconds")

	flag.Var(&c_excludes, "cexc", "a single container exclude")
	flag.Var(&i_excludes, "iexc", "a single image exclude")
	flag.Var(&c_includes, "cinc", "a single container include")
	flag.Var(&i_includes, "iinc", "a single image incclude")

	flag.Parse()

	var resptr = NewUndertakerData()

	if len(container_excludes_file) > 0 {
		ptr, err := loadFile(container_excludes_file)
		if err != nil {
			return nil, err
		}

		resptr.ContainerExc = generateRegexp(ptr)
	}

	if len(image_excludes_file) > 0 {
		ptr, err := loadFile(image_excludes_file)
		if err != nil {
			return nil, err
		}

		resptr.ImageExc = generateRegexp(ptr)
	}

	if len(c_excludes) > 0 {
		*resptr.ContainerExc = append(*resptr.ContainerExc, *generateRegexp(&c_excludes)...)
	}

	if len(i_excludes) > 0 {
		*resptr.ImageExc = append(*resptr.ImageExc, *generateRegexp(&i_excludes)...)
	}

	if len(c_includes) > 0 {
		*resptr.ContainerInc = append(*resptr.ContainerInc, *generateRegexp(&c_includes)...)
	}

	if len(i_includes) > 0 {
		*resptr.ImageInc = append(*resptr.ImageInc, *generateRegexp(&i_includes)...)
	}

	return resptr, nil
}
Exemplo n.º 29
0
func main() {
	cfg := nsq.NewConfig()
	// TODO: remove, deprecated
	flag.Var(&nsq.ConfigFlag{cfg}, "reader-opt", "(deprecated) use --consumer-opt")
	flag.Var(&nsq.ConfigFlag{cfg}, "consumer-opt", "option to passthrough to nsq.Consumer (may be given multiple times, http://godoc.org/github.com/absolute8511/go-nsq#Config)")

	flag.Parse()

	if *showVersion {
		fmt.Printf("nsq_tail v%s\n", version.Binary)
		return
	}

	if *channel == "" {
		rand.Seed(time.Now().UnixNano())
		*channel = fmt.Sprintf("tail%06d#ephemeral", rand.Int()%999999)
	}

	if *topic == "" {
		log.Fatal("--topic is required")
	}

	if len(lookupdHTTPAddrs) == 0 {
		log.Fatal("--nsqd-tcp-address or --lookupd-http-address required")
	}

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

	// Don't ask for more messages than we want
	if *totalMessages > 0 && *totalMessages < *maxInFlight {
		*maxInFlight = *totalMessages
	}

	cfg.UserAgent = fmt.Sprintf("nsq_tail/%s go-nsq/%s", version.Binary, nsq.VERSION)
	cfg.MaxInFlight = *maxInFlight

	consumer, err := nsq.NewPartitionConsumer(*topic, *partition, *channel, cfg)
	if err != nil {
		log.Fatal(err)
	}

	consumer.AddHandler(&TailHandler{totalMessages: *totalMessages})

	err = consumer.ConnectToNSQLookupds(lookupdHTTPAddrs)
	if err != nil {
		log.Fatal(err)
	}

	for {
		select {
		case <-consumer.StopChan:
			return
		case <-sigChan:
			consumer.Stop()
		}
	}
}
Exemplo n.º 30
0
func main() {
	var kind string = "files"
	var ndirs, nfiles int
	var paths []string

	flag.Var(&_fthreshold, "ft", "file sizes <= threshhold will not be considered")
	flag.Var(&_dthreshold, "dt", "directory sizes <= threshhold will not be considered")
	//fmt.Printf("dedup\n")
	hf = aeshash.NewAES(0)
	flag.Parse()
	if *pat != "" {
		re, err := regexp.Compile(*pat)
		if err != nil {
			return
		}
		patre = re
	}
	if *dd != "" {
		re, err := regexp.Compile(*dd)
		if err != nil {
			return
		}
		ddre = re
	}
	fthreshold = int64(_fthreshold.V)
	dthreshold = int64(_dthreshold.V)
	//fmt.Printf("fthreshold=%d\n", fthreshold)
	//fmt.Printf("dthreshold=%d\n", dthreshold)
	if *dirf {
		kind = "dirs"
	}

	if len(flag.Args()) != 0 {
		for _, path := range flag.Args() {
			fi, err := os.Stat(path)
			if err != nil || fi == nil {
				fmt.Printf("fi=%#v, err=%v\n", fi, err)
				panic("bad")
			}
			if fi.Mode()&os.ModeDir == os.ModeDir {
				ndirs++
			} else {
				nfiles++
			}
			paths = append(paths, path)
		}
	}

	scan(paths, ndirs)
	if *s {
		asort()
		check2(kind, ndirs)

	} else {
		check(kind, ndirs)
	}
}