Golang IntVar示例

说明

golang intvar示例是从最受好评的开源项目中提取的实现代码,你可以参考下面示例的使用方式。

编程语言: Golang

命名空间/包名称: flag

示例#1
文件: settings.go 项目: morsharon/gor

func init() {
	flag.Usage = usage

	flag.BoolVar(&Settings.verbose, "verbose", false, "Turn on verbose/debug output")
	flag.BoolVar(&Settings.stats, "stats", false, "Turn on queue stats output")

	flag.BoolVar(&Settings.splitOutput, "split-output", false, "By default each output gets same traffic. If set to `true` it splits traffic equally among all outputs.")

	flag.Var(&Settings.inputDummy, "input-dummy", "Used for testing outputs. Emits 'Get /' request every 1s")
	flag.Var(&Settings.outputDummy, "output-dummy", "Used for testing inputs. Just prints data coming from inputs.")

	flag.Var(&Settings.inputTCP, "input-tcp", "Used for internal communication between Gor instances. Example: \n\t# Receive requests from other Gor instances on 28020 port, and redirect output to staging\n\tgor --input-tcp :28020 --output-http staging.com")
	flag.Var(&Settings.outputTCP, "output-tcp", "Used for internal communication between Gor instances. Example: \n\t# Listen for requests on 80 port and forward them to other Gor instance on 28020 port\n\tgor --input-raw :80 --output-tcp replay.local:28020")
	flag.BoolVar(&Settings.outputTCPStats, "output-tcp-stats", false, "Report TCP output queue stats to console every 5 seconds.")

	flag.Var(&Settings.inputFile, "input-file", "Read requests from file: \n\tgor --input-file ./requests.gor --output-http staging.com")
	flag.Var(&Settings.outputFile, "output-file", "Write incoming requests to file: \n\tgor --input-raw :80 --output-file ./requests.gor")

	flag.Var(&Settings.inputRAW, "input-raw", "Capture traffic from given port (use RAW sockets and require *sudo* access):\n\t# Capture traffic from 8080 port\n\tgor --input-raw :8080 --output-http staging.com")

	flag.Var(&Settings.inputHTTP, "input-http", "Read requests from HTTP, should be explicitly sent from your application:\n\t# Listen for http on 9000\n\tgor --input-http :9000 --output-http staging.com")

	flag.Var(&Settings.outputHTTP, "output-http", "Forwards incoming requests to given http address.\n\t# Redirect all incoming requests to staging.com address \n\tgor --input-raw :80 --output-http http://staging.com")
	flag.IntVar(&Settings.outputHTTPConfig.workers, "output-http-workers", 0, "Gor uses dynamic worker scaling by default.  Enter a number to run a set number of workers.")
	flag.IntVar(&Settings.outputHTTPConfig.redirectLimit, "output-http-redirects", 0, "Enable how often redirects should be followed.")
	flag.Var(&Settings.modifierConfig.headers, "output-http-header", "Inject additional headers to http reqest:\n\tgor --input-raw :8080 --output-http staging.com --output-http-header 'User-Agent: Gor'")
	flag.Var(&Settings.modifierConfig.methods, "output-http-method", "Whitelist of HTTP methods to replay. Anything else will be dropped:\n\tgor --input-raw :8080 --output-http staging.com --output-http-method GET --output-http-method OPTIONS")
	flag.Var(&Settings.modifierConfig.urlRegexp, "output-http-url-regexp", "A regexp to match requests against. Anything else will be dropped:\n\t gor --input-raw :8080 --output-http staging.com --output-http-url-regexp ^www.")
	flag.Var(&Settings.modifierConfig.urlRewrite, "output-http-rewrite-url", "Rewrite the requst url based on a mapping:\n\tgor --input-raw :8080 --output-http staging.com --output-http-rewrite-url /xml_test/interface.php:/api/service.do")
	flag.Var(&Settings.modifierConfig.headerFilters, "output-http-header-filter", "A regexp to match a specific header against. Requests with non-matching headers will be dropped:\n\t gor --input-raw :8080 --output-http staging.com --output-http-header-filter api-version:^v1")
	flag.Var(&Settings.modifierConfig.headerHashFilters, "output-http-header-hash-filter", "Takes a fraction of requests, consistently taking or rejecting a request based on the FNV32-1A hash of a specific header. The fraction must have a denominator that is a power of two:\n\t gor --input-raw :8080 --output-http staging.com --output-http-header-hash-filter user-id:1/4")
	flag.BoolVar(&Settings.outputHTTPConfig.stats, "output-http-stats", false, "Report http output queue stats to console every 5 seconds.")

	flag.StringVar(&Settings.outputHTTPConfig.elasticSearch, "output-http-elasticsearch", "", "Send request and response stats to ElasticSearch:\n\tgor --input-raw :8080 --output-http staging.com --output-http-elasticsearch 'es_host:api_port/index_name'")
}

示例#2
文件: app.go 项目: uhhhclem/sentinels

func main() {

	flag.IntVar(&pc, "pc", 3, "player count (3-5)")
	flag.IntVar(&lp, "lp", 50, "target loss percent (1-99, default 50")
	flag.IntVar(&rg, "rg", 10, "allowable difficulty variance around target loss percent (0-100, default 10")

	var err error

	if err = validateFlags(); err != nil {
		fmt.Println(err)
		return
	}

	s, i, err := sentinels.FindSetup(pc, lp, rg, []sentinels.ExpansionType{sentinels.BaseSet, sentinels.MiniExpansion})
	if err != nil {
		fmt.Println(err)
		return
	}
	if s != nil {
		fmt.Printf("\nFound in %d iterations:\n\n", i)
		fmt.Printf("%s", s)
	} else {
		fmt.Printf("\nNo setup found in %d iterations.\n", i)
	}

}

示例#3
文件: bubtrail.go 项目: rif/golang-stuff

func init() {
	flag.IntVar(&size, "s", 40, "bubble size")
	flag.IntVar(&niter, "n", 200, "number of iterations")
	flag.Float64Var(&opacity, "o", 0.5, "opacity")
	flag.Parse()
	rand.Seed(int64(time.Now().Nanosecond()) % 1e9)
}

示例#4
文件: main.go 项目: cheetah0216/kafka-pusher

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")
}

示例#5
文件: main.go 项目: olivierHa/buckytools

func main() {
	hostname, err := os.Hostname()
	if err != nil {
		hostname = "unknown"
	}

	flag.StringVar(&prefix, "p", fmt.Sprintf("bucky-pickle-relay.%s", hostname),
		"Prefix for internally generated metrics.")
	flag.StringVar(&bindTo, "b", ":2004",
		"Address to bind to for incoming connections.")
	flag.BoolVar(&debug, "d", false,
		"Debug mode.")
	flag.IntVar(&pickleTimeout, "t", 300,
		"Timeout in seconds on incoming pickle protocol TCP connections.")
	flag.IntVar(&sendTimeout, "s", 30,
		"TCP timeout in seconds for outgoing line protocol connections.")
	flag.IntVar(&maxPickleSize, "x", 1*1024*1024,
		"Maximum pickle size accepted.")
	flag.IntVar(&pickleQueueSize, "q", 0,
		"Internal buffer sizes.")
	flag.DurationVar(&metricInterval, "i", 60,
		"Interval in seconds between reporting of internal metrics.")
	flag.Parse()
	if flag.NArg() != 1 {
		usage()
	}

	log.Printf("bucky-pickle-relay Copyright 2015 42 Lines, Inc.")
	carbonRelay = flag.Arg(0)
	log.Printf("Sending line protocol data to %s", carbonRelay)
	log.Printf("Reporting internal metrics under %s", prefix)

	metrics := serveForever()
	plainTextOut(metrics)
}

示例#6
文件: flags.go 项目: newrelic-forks/goworker

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")
}

示例#7
文件: e2e_test.go 项目: pologood/kubernetes

func init() {
	// Turn on verbose by default to get spec names
	config.DefaultReporterConfig.Verbose = true

	// Turn on EmitSpecProgress to get spec progress (especially on interrupt)
	config.GinkgoConfig.EmitSpecProgress = true

	// Randomize specs as well as suites
	config.GinkgoConfig.RandomizeAllSpecs = true

	flag.StringVar(&testContext.KubeConfig, clientcmd.RecommendedConfigPathFlag, "", "Path to kubeconfig containing embedded authinfo.")
	flag.StringVar(&testContext.KubeContext, clientcmd.FlagContext, "", "kubeconfig context to use/override. If unset, will use value from 'current-context'")
	flag.StringVar(&testContext.CertDir, "cert-dir", "", "Path to the directory containing the certs. Default is empty, which doesn't use certs.")
	flag.StringVar(&testContext.Host, "host", "", "The host, or apiserver, to connect to")
	flag.StringVar(&testContext.RepoRoot, "repo-root", "../../", "Root directory of kubernetes repository, for finding test files.")
	flag.StringVar(&testContext.Provider, "provider", "", "The name of the Kubernetes provider (gce, gke, local, vagrant, etc.)")
	flag.StringVar(&testContext.KubectlPath, "kubectl-path", "kubectl", "The kubectl binary to use. For development, you might use 'cluster/kubectl.sh' here.")
	flag.StringVar(&testContext.OutputDir, "e2e-output-dir", "/tmp", "Output directory for interesting/useful test data, like performance data, benchmarks, and other metrics.")
	flag.StringVar(&testContext.prefix, "prefix", "e2e", "A prefix to be added to cloud resources created during testing.")

	// TODO: Flags per provider?  Rename gce-project/gce-zone?
	flag.StringVar(&cloudConfig.MasterName, "kube-master", "", "Name of the kubernetes master. Only required if provider is gce or gke")
	flag.StringVar(&cloudConfig.ProjectID, "gce-project", "", "The GCE project being used, if applicable")
	flag.StringVar(&cloudConfig.Zone, "gce-zone", "", "GCE zone being used, if applicable")
	flag.StringVar(&cloudConfig.Cluster, "gke-cluster", "", "GKE name of cluster being used, if applicable")
	flag.StringVar(&cloudConfig.NodeInstanceGroup, "node-instance-group", "", "Name of the managed instance group for nodes. Valid only for gce, gke or aws")
	flag.IntVar(&cloudConfig.NumNodes, "num-nodes", -1, "Number of nodes in the cluster")

	flag.StringVar(&cloudConfig.ClusterTag, "cluster-tag", "", "Tag used to identify resources.  Only required if provider is aws.")
	flag.IntVar(&testContext.MinStartupPods, "minStartupPods", 0, "The number of pods which we need to see in 'Running' state with a 'Ready' condition of true, before we try running tests. This is useful in any cluster which needs some base pod-based services running before it can be used.")
	flag.StringVar(&testContext.UpgradeTarget, "upgrade-target", "ci/latest", "Version to upgrade to (e.g. 'release/stable', 'release/latest', 'ci/latest', '0.19.1', '0.19.1-669-gabac8c8') if doing an upgrade test.")
	flag.StringVar(&testContext.PrometheusPushGateway, "prom-push-gateway", "", "The URL to prometheus gateway, so that metrics can be pushed during e2es and scraped by prometheus. Typically something like 127.0.0.1:9091.")
	flag.BoolVar(&testContext.VerifyServiceAccount, "e2e-verify-service-account", true, "If true tests will verify the service account before running.")
}

示例#8
文件: options.go 项目: postfix/logstash-forwarder

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")
}

示例#9
文件: sandhog.go 项目: hut8/sandhog

func loadConfig() (*configStruct, error) {
	var config configStruct

	flag.IntVar(&config.localPort, "local-port", 0, "Local port on which to listen to forward from remote")
	flag.IntVar(&config.remotePort, "remote-port", 0, "Remote port on which to listen to forward to local")
	flag.StringVar(&config.keyPath, "key", "", "Path to id_rsa")
	flag.StringVar(&config.remoteHost, "host", "", "Remote host to forward data from")

	flag.Parse()

	if config.localPort == 0 {
		return nil, configError{"Local port must be specified"}
	}
	if config.remotePort == 0 {
		return nil, configError{"Remote port must be specified"}
	}
	if config.keyPath == "" {
		return nil, configError{"Key path must be specified"}
	}
	if config.remoteHost == "" {
		return nil, configError{"Remote host must be specified"}
	}

	return &config, nil
}

示例#10
文件: test_context.go 项目: astropuffin/kubernetes

// Register flags specific to the cluster e2e test suite.
func RegisterClusterFlags() {
	flag.BoolVar(&TestContext.VerifyServiceAccount, "e2e-verify-service-account", true, "If true tests will verify the service account before running.")
	flag.StringVar(&TestContext.KubeConfig, clientcmd.RecommendedConfigPathFlag, os.Getenv(clientcmd.RecommendedConfigPathEnvVar), "Path to kubeconfig containing embedded authinfo.")
	flag.StringVar(&TestContext.KubeContext, clientcmd.FlagContext, "", "kubeconfig context to use/override. If unset, will use value from 'current-context'")
	flag.StringVar(&TestContext.KubeAPIContentType, "kube-api-content-type", "", "ContentType used to communicate with apiserver")
	flag.StringVar(&federatedKubeContext, "federated-kube-context", "federation-cluster", "kubeconfig context for federation-cluster.")

	flag.StringVar(&TestContext.KubeVolumeDir, "volume-dir", "/var/lib/kubelet", "Path to the directory containing the kubelet volumes.")
	flag.StringVar(&TestContext.CertDir, "cert-dir", "", "Path to the directory containing the certs. Default is empty, which doesn't use certs.")
	flag.StringVar(&TestContext.RepoRoot, "repo-root", "../../", "Root directory of kubernetes repository, for finding test files.")
	flag.StringVar(&TestContext.Provider, "provider", "", "The name of the Kubernetes provider (gce, gke, local, vagrant, etc.)")
	flag.StringVar(&TestContext.KubectlPath, "kubectl-path", "kubectl", "The kubectl binary to use. For development, you might use 'cluster/kubectl.sh' here.")
	flag.StringVar(&TestContext.OutputDir, "e2e-output-dir", "/tmp", "Output directory for interesting/useful test data, like performance data, benchmarks, and other metrics.")
	flag.StringVar(&TestContext.Prefix, "prefix", "e2e", "A prefix to be added to cloud resources created during testing.")
	flag.StringVar(&TestContext.ContainerRuntime, "container-runtime", "docker", "The container runtime of cluster VM instances (docker or rkt).")
	flag.StringVar(&TestContext.MasterOSDistro, "master-os-distro", "debian", "The OS distribution of cluster master (debian, trusty, or coreos).")
	flag.StringVar(&TestContext.NodeOSDistro, "node-os-distro", "debian", "The OS distribution of cluster VM instances (debian, trusty, or coreos).")

	// TODO: Flags per provider?  Rename gce-project/gce-zone?
	cloudConfig := &TestContext.CloudConfig
	flag.StringVar(&cloudConfig.MasterName, "kube-master", "", "Name of the kubernetes master. Only required if provider is gce or gke")
	flag.StringVar(&cloudConfig.ProjectID, "gce-project", "", "The GCE project being used, if applicable")
	flag.StringVar(&cloudConfig.Zone, "gce-zone", "", "GCE zone being used, if applicable")
	flag.StringVar(&cloudConfig.Cluster, "gke-cluster", "", "GKE name of cluster being used, if applicable")
	flag.StringVar(&cloudConfig.NodeInstanceGroup, "node-instance-group", "", "Name of the managed instance group for nodes. Valid only for gce, gke or aws. If there is more than one group: comma separated list of groups.")
	flag.IntVar(&cloudConfig.NumNodes, "num-nodes", -1, "Number of nodes in the cluster")

	flag.StringVar(&cloudConfig.ClusterTag, "cluster-tag", "", "Tag used to identify resources.  Only required if provider is aws.")
	flag.IntVar(&TestContext.MinStartupPods, "minStartupPods", 0, "The number of pods which we need to see in 'Running' state with a 'Ready' condition of true, before we try running tests. This is useful in any cluster which needs some base pod-based services running before it can be used.")
	flag.DurationVar(&TestContext.SystemPodsStartupTimeout, "system-pods-startup-timeout", 10*time.Minute, "Timeout for waiting for all system pods to be running before starting tests.")
	flag.StringVar(&TestContext.UpgradeTarget, "upgrade-target", "ci/latest", "Version to upgrade to (e.g. 'release/stable', 'release/latest', 'ci/latest', '0.19.1', '0.19.1-669-gabac8c8') if doing an upgrade test.")
	flag.StringVar(&TestContext.PrometheusPushGateway, "prom-push-gateway", "", "The URL to prometheus gateway, so that metrics can be pushed during e2es and scraped by prometheus. Typically something like 127.0.0.1:9091.")
	flag.BoolVar(&TestContext.CleanStart, "clean-start", false, "If true, purge all namespaces except default and system before running tests. This serves to Cleanup test namespaces from failed/interrupted e2e runs in a long-lived cluster.")
	flag.BoolVar(&TestContext.GarbageCollectorEnabled, "garbage-collector-enabled", false, "Set to true if the garbage collector is enabled in the kube-apiserver and kube-controller-manager, then some tests will rely on the garbage collector to delete dependent resources.")
}

示例#11
文件: main.go 项目: pd/dripdripgo

func load() (*Options, error) {
	var drippers, startID int
	var heapStr string

	flag.StringVar(&licenseKey, "key", "", "License key")
	flag.IntVar(&startID, "start", 1, "ID of first dripper")
	flag.IntVar(&drippers, "count", 1, "Number of drippers")
	flag.StringVar(&heapStr, "heap", "512 GB", "Heap size to report")
	flag.BoolVar(&debugMode, "debug", false, "Dump HTTP traffic")
	flag.Parse()

	if licenseKey == "" {
		return nil, errors.New("License key required")
	}

	heapSize, err := bytesize.Parse([]byte(heapStr))
	if err != nil {
		return nil, err
	}

	return &Options{
		Drippers: drippers,
		HeapSize: uint64(heapSize),
		StartID:  startID,
	}, nil
}

示例#12
文件: csv2map.go 项目: sjhitchner/csv2map

func init() {
	flag.IntVar(&keyIndex, "key", 0, USAGE_KEY_INDEX)
	flag.IntVar(&keyIndex, "k", 0, USAGE_KEY_INDEX)

	flag.IntVar(&valueIndex, "value", 0, USAGE_VALUE_INDEX)
	flag.IntVar(&valueIndex, "v", 0, USAGE_VALUE_INDEX)

	flag.StringVar(&mapName, "map", "", USAGE_MAP_NAME)
	flag.StringVar(&mapName, "m", "", USAGE_MAP_NAME)

	flag.StringVar(&packageName, "package", "", USAGE_PACKAGE_NAME)
	flag.StringVar(&packageName, "p", "", USAGE_PACKAGE_NAME)

	flag.StringVar(&fileName, "in", "", USAGE_FILE_NAME)
	flag.StringVar(&fileName, "i", "", USAGE_FILE_NAME)

	flag.StringVar(&delimiter, "delimiter", DEFAULT_DELIMITER, USAGE_DELIMITER)
	flag.StringVar(&delimiter, "d", DEFAULT_DELIMITER, USAGE_DELIMITER)

	flag.BoolVar(&ignoreHeader, "header", false, USAGE_HEADER)
	flag.BoolVar(&ignoreHeader, "h", false, USAGE_HEADER)

	flag.BoolVar(&test, "test", false, USAGE_INSPECT)
	flag.BoolVar(&test, "t", false, USAGE_INSPECT)
}

示例#13
文件: config.go 项目: littleyang/vitess

func init() {
	flag.IntVar(&qsConfig.PoolSize, "queryserver-config-pool-size", DefaultQsConfig.PoolSize, "query server connection pool size, connection pool is used by regular queries (non streaming, not in a transaction)")
	flag.IntVar(&qsConfig.StreamPoolSize, "queryserver-config-stream-pool-size", DefaultQsConfig.StreamPoolSize, "query server stream pool size, stream pool is used by stream queries: queries that return results to client in a streaming fashion")
	flag.IntVar(&qsConfig.TransactionCap, "queryserver-config-transaction-cap", DefaultQsConfig.TransactionCap, "query server transaction cap is the maximum number of transactions allowed to happen at any given point of a time for a single vttablet. E.g. by setting transaction cap to 100, there are at most 100 transactions will be processed by a vttablet and the 101th transaction will be blocked (and fail if it cannot get connection within specified timeout)")
	flag.Float64Var(&qsConfig.TransactionTimeout, "queryserver-config-transaction-timeout", DefaultQsConfig.TransactionTimeout, "query server transaction timeout (in seconds), a transaction will be killed if it takes longer than this value")
	flag.IntVar(&qsConfig.MaxResultSize, "queryserver-config-max-result-size", DefaultQsConfig.MaxResultSize, "query server max result size, maximum number of rows allowed to return from vttablet for non-streaming queries.")
	flag.IntVar(&qsConfig.MaxDMLRows, "queryserver-config-max-dml-rows", DefaultQsConfig.MaxDMLRows, "query server max dml rows per statement, maximum number of rows allowed to return at a time for an upadte or delete with either 1) an equality where clauses on primary keys, or 2) a subselect statement. For update and delete statements in above two categories, vttablet will split the original query into multiple small queries based on this configuration value. ")
	flag.IntVar(&qsConfig.StreamBufferSize, "queryserver-config-stream-buffer-size", DefaultQsConfig.StreamBufferSize, "query server stream buffer size, the maximum number of bytes sent from vttablet for each stream call.")
	flag.IntVar(&qsConfig.QueryCacheSize, "queryserver-config-query-cache-size", DefaultQsConfig.QueryCacheSize, "query server query cache size, maximum number of queries to be cached. vttablet analyzes every incoming query and generate a query plan, these plans are being cached in a lru cache. This config controls the capacity of the lru cache.")
	flag.Float64Var(&qsConfig.SchemaReloadTime, "queryserver-config-schema-reload-time", DefaultQsConfig.SchemaReloadTime, "query server schema reload time, how often vttablet reloads schemas from underlying MySQL instance in seconds. vttablet keeps table schemas in its own memory and periodically refreshes it from MySQL. This config controls the reload time.")
	flag.Float64Var(&qsConfig.QueryTimeout, "queryserver-config-query-timeout", DefaultQsConfig.QueryTimeout, "query server query timeout (in seconds), this is the query timeout in vttablet side. If a query takes more than this timeout, it will be killed.")
	flag.Float64Var(&qsConfig.TxPoolTimeout, "queryserver-config-txpool-timeout", DefaultQsConfig.TxPoolTimeout, "query server transaction pool timeout, it is how long vttablet waits if tx pool is full")
	flag.Float64Var(&qsConfig.IdleTimeout, "queryserver-config-idle-timeout", DefaultQsConfig.IdleTimeout, "query server idle timeout (in seconds), vttablet manages various mysql connection pools. This config means if a connection has not been used in given idle timeout, this connection will be removed from pool. This effectively manages number of connection objects and optimize the pool performance.")
	flag.Float64Var(&qsConfig.SpotCheckRatio, "queryserver-config-spot-check-ratio", DefaultQsConfig.SpotCheckRatio, "query server rowcache spot check frequency (in [0, 1]), if rowcache is enabled, this value determines how often a row retrieved from the rowcache is spot-checked against MySQL.")
	flag.BoolVar(&qsConfig.StrictMode, "queryserver-config-strict-mode", DefaultQsConfig.StrictMode, "allow only predictable DMLs and enforces MySQL's STRICT_TRANS_TABLES")
	// tableacl related configurations.
	flag.BoolVar(&qsConfig.StrictTableAcl, "queryserver-config-strict-table-acl", DefaultQsConfig.StrictTableAcl, "only allow queries that pass table acl checks")
	flag.BoolVar(&qsConfig.EnableTableAclDryRun, "queryserver-config-enable-table-acl-dry-run", DefaultQsConfig.EnableTableAclDryRun, "If this flag is enabled, tabletserver will emit monitoring metrics and let the request pass regardless of table acl check results")
	flag.StringVar(&qsConfig.TableAclExemptACL, "queryserver-config-acl-exempt-acl", DefaultQsConfig.TableAclExemptACL, "an acl that exempt from table acl checking (this acl is free to access any vitess tables).")
	flag.BoolVar(&qsConfig.TerseErrors, "queryserver-config-terse-errors", DefaultQsConfig.TerseErrors, "prevent bind vars from escaping in returned errors")
	flag.BoolVar(&qsConfig.EnablePublishStats, "queryserver-config-enable-publish-stats", DefaultQsConfig.EnablePublishStats, "set this flag to true makes queryservice publish monitoring stats")
	flag.BoolVar(&qsConfig.RowCache.Enabled, "enable-rowcache", DefaultQsConfig.RowCache.Enabled, "set this flag to enable rowcache. The rest of the rowcache parameters will also need to be accordingly specified.")
	flag.StringVar(&qsConfig.RowCache.Binary, "rowcache-bin", DefaultQsConfig.RowCache.Binary, "rowcache binary file, vttablet launches a memcached if rowcache is enabled. This config specifies the location of the memcache binary.")
	flag.IntVar(&qsConfig.RowCache.Memory, "rowcache-memory", DefaultQsConfig.RowCache.Memory, "rowcache max memory usage in MB")
	flag.StringVar(&qsConfig.RowCache.Socket, "rowcache-socket", DefaultQsConfig.RowCache.Socket, "socket filename hint: a unique filename will be generated based on this input")
	flag.IntVar(&qsConfig.RowCache.Connections, "rowcache-connections", DefaultQsConfig.RowCache.Connections, "rowcache max simultaneous connections")
	flag.IntVar(&qsConfig.RowCache.Threads, "rowcache-threads", DefaultQsConfig.RowCache.Threads, "rowcache number of threads")
	flag.BoolVar(&qsConfig.RowCache.LockPaged, "rowcache-lock-paged", DefaultQsConfig.RowCache.LockPaged, "whether rowcache locks down paged memory")
	flag.StringVar(&qsConfig.RowCache.StatsPrefix, "rowcache-stats-prefix", DefaultQsConfig.RowCache.StatsPrefix, "rowcache stats prefix, rowcache will export various metrics and this config specifies the metric prefix")
	flag.StringVar(&qsConfig.StatsPrefix, "stats-prefix", DefaultQsConfig.StatsPrefix, "prefix for variable names exported via expvar")
	flag.StringVar(&qsConfig.DebugURLPrefix, "debug-url-prefix", DefaultQsConfig.DebugURLPrefix, "debug url prefix, vttablet will report various system debug pages and this config controls the prefix of these debug urls")
	flag.StringVar(&qsConfig.PoolNamePrefix, "pool-name-prefix", DefaultQsConfig.PoolNamePrefix, "pool name prefix, vttablet has several pools and each of them has a name. This config specifies the prefix of these pool names")
	flag.BoolVar(&qsConfig.EnableAutoCommit, "enable-autocommit", DefaultQsConfig.EnableAutoCommit, "if the flag is on, a DML outsides a transaction will be auto committed.")
}

示例#14
文件: wsctl.go 项目: miconda/wsctl

//
// initialize application components
func init() {
	// command line arguments
	flag.Usage = func() {
		fmt.Fprintf(os.Stderr, "Usage of %s (v%s):\n", filepath.Base(os.Args[0]), wsctlVersion)
		fmt.Fprintf(os.Stderr, "    (each option has short and long version)\n")
		flag.PrintDefaults()
		os.Exit(1)
	}
	flag.StringVar(&cliops.wsauser, "auser", cliops.wsauser, "username to be used for authentication")
	flag.StringVar(&cliops.wsapasswd, "apasswd", cliops.wsapasswd, "password to be used for authentication")
	flag.BoolVar(&cliops.wscrlf, "crlf", cliops.wscrlf, "replace '\\n' with '\\r\\n' inside the data to be sent (true|false)")
	flag.StringVar(&cliops.wsfields, "fields", cliops.wsfields, "path to the json fields file")
	flag.StringVar(&cliops.wsfields, "f", cliops.wsfields, "path to the json fields file")
	flag.BoolVar(&cliops.wsinsecure, "insecure", cliops.wsinsecure, "skip tls certificate validation for wss (true|false)")
	flag.BoolVar(&cliops.wsinsecure, "i", cliops.wsinsecure, "skip tls certificate validation for wss (true|false)")
	flag.StringVar(&cliops.wsorigin, "origin", cliops.wsorigin, "origin http url")
	flag.StringVar(&cliops.wsorigin, "o", cliops.wsorigin, "origin http url")
	flag.StringVar(&cliops.wsproto, "proto", cliops.wsproto, "websocket sub-protocol")
	flag.StringVar(&cliops.wsproto, "p", cliops.wsproto, "websocket sub-protocol")
	flag.BoolVar(&cliops.wsreceive, "receive", cliops.wsreceive, "wait to receive response from ws server (true|false)")
	flag.BoolVar(&cliops.wsreceive, "r", cliops.wsreceive, "wait to receive response from ws server (true|false)")
	flag.StringVar(&cliops.wstemplate, "template", cliops.wstemplate, "path to template file (mandatory parameter)")
	flag.StringVar(&cliops.wstemplate, "t", cliops.wstemplate, "path to template file (mandatory parameter)")
	flag.StringVar(&cliops.wsurl, "url", cliops.wsurl, "websocket url (ws://... or wss://...)")
	flag.StringVar(&cliops.wsurl, "u", cliops.wsurl, "websocket url (ws://... or wss://...)")
	flag.BoolVar(&cliops.version, "version", cliops.version, "print version")
	flag.IntVar(&cliops.wstimeoutrecv, "timeout-recv", cliops.wstimeoutrecv, "timeout waiting to receive data (milliseconds)")
	flag.IntVar(&cliops.wstimeoutsend, "timeout-send", cliops.wstimeoutsend, "timeout trying to send data (milliseconds)")
}

示例#15
文件: lockrun.go 项目: josgilmo/Lockrungo

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
}

示例#16
文件: main.go 项目: cmac1000/simple-reverse-proxy

func init() {
	var (
		scheme        string
		host          string
		port          int
		listeningPort int
		allowExternal bool
	)
	flag.IntVar(&port, "port", 8000, "Port to reverse proxy")
	flag.StringVar(&host, "host", "localhost", "Host to reverse proxy")
	flag.StringVar(&scheme, "scheme", "http", "Scheme to reverse proxy")
	flag.IntVar(&listeningPort, "listening-port", 80, "Port to listen on")
	flag.BoolVar(&allowExternal, "allow-external-connections", false, "Allow other computers to connect to your HTTP server")
	flag.Parse()

	Url = &url.URL{
		Scheme: scheme,
		Host:   fmt.Sprintf("%s:%d", host, port),
	}

	if allowExternal {
		ListenOn = fmt.Sprintf(":%d", listeningPort)
	} else {
		ListenOn = fmt.Sprintf("127.0.0.1:%d", listeningPort)
	}

}

示例#17
文件: test_mset.go 项目: cougar731/codis

func (tc *TestMsetTestCase) init() {
	flag.StringVar(&tc.proxy, "proxy", "", "redis host:port")
	flag.IntVar(&tc.group, "group", 8, "# of test players")
	flag.IntVar(&tc.round, "round", 10000, "# of rounds per test player")
	flag.IntVar(&tc.nkeys, "nkeys", 10000, "# of keys per test")
	flag.IntVar(&tc.ntags, "ntags", 1000, "# of tags")
}

示例#18
文件: PIDuino-ui.go 项目: gregose/PIDuino

func init() {
	flag.IntVar(&port, "port", 80, "Webserver port.")
	flag.IntVar(&port, "p", 80, "Webserver port (shorthand).")

	flag.BoolVar(&passThrough, "through", false, "Pass serial input to STDOUT.")
	flag.BoolVar(&passThrough, "t", false, "Pass serial input to STDOUT (shorthand).")

	flag.BoolVar(&logging, "log", false, "Log HTTP requests to STDOUT")
	flag.BoolVar(&logging, "l", false, "Log HTTP requests to STDOUT (shorthand).")

	flag.BoolVar(&devMode, "dev", false, "Dev mode")
	flag.BoolVar(&devMode, "d", false, "Dev mode (shorthand).")

	flag.IntVar(&maxLogSize, "num", 180, "Number of previous temperatures to keep in memory.")
	flag.IntVar(&maxLogSize, "n", 180, "Number of previous temperatures to keep in memory (shorthand).")

	flag.UintVar(&baudRate, "baud", 115200, "Serial port baud rate.")
	flag.UintVar(&baudRate, "b", 115200, "Serial port baud rate.")

	flag.StringVar(&serialPort, "serial", "/dev/ttyATH0", "Serial port device.")
	flag.StringVar(&serialPort, "s", "/dev/ttyATH0", "Serial port device.")

	// Dev starting values
	lastDevGrouphead = 100.0
	lastDevBoiler = 180.0

	// Set up hub
	h.Connections = make(map[*socket]bool)
	h.Pipe = make(chan string, 1)
}

示例#19
文件: go-loadtest.go 项目: RobinUS2/go-loadtest

// Init settings
func init() {
    flag.StringVar(&urlsIn, "urls", "", "Urls to benchmark")
    flag.IntVar(&concurrency, "c", 8*cpuCount, "Concurrency")
    flag.IntVar(&requests, "n", 10000, "Amount of requests")
    flag.IntVar(&timeoutTime, "t", 10, "Timeout in seconds")
    flag.Parse()
}

示例#20
文件: genfiles.go 项目: GDXN/syncthing

func main() {
	var files int
	var maxexp int
	var srcname string

	flag.IntVar(&files, "files", 1000, "Number of files")
	flag.IntVar(&maxexp, "maxexp", 20, "Maximum file size (max = 2^n + 128*1024 B)")
	flag.StringVar(&srcname, "src", "/usr/share/dict/words", "Source material")
	flag.Parse()

	fd, err := os.Open(srcname)
	if err != nil {
		log.Fatal(err)
	}

	for i := 0; i < files; i++ {
		n := name()
		p0 := filepath.Join(string(n[0]), n[0:2])
		err = os.MkdirAll(p0, 0755)
		if err != nil {
			log.Fatal(err)
		}

		s := 1 << uint(mr.Intn(maxexp))
		a := 128 * 1024
		if a > s {
			a = s
		}
		s += mr.Intn(a)

		src := io.LimitReader(&inifiteReader{fd}, int64(s))

		p1 := filepath.Join(p0, n)
		dst, err := os.Create(p1)
		if err != nil {
			log.Fatal(err)
		}

		_, err = io.Copy(dst, src)
		if err != nil {
			log.Fatal(err)
		}

		err = dst.Close()
		if err != nil {
			log.Fatal(err)
		}

		err = os.Chmod(p1, os.FileMode(mr.Intn(0777)|0400))
		if err != nil {
			log.Fatal(err)
		}

		t := time.Now().Add(-time.Duration(mr.Intn(30*86400)) * time.Second)
		err = os.Chtimes(p1, t, t)
		if err != nil {
			log.Fatal(err)
		}
	}
}

示例#21
文件: gotestcover.go 项目: crazytyper/gotestcover

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
}

示例#22
文件: test_client3.go 项目: alxzh/two-queues

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")

}

示例#23
文件: main.go 项目: jcdny/bugnuts

func init() {
	//	log.SetFlags(log.Ltime | log.Lmicroseconds | log.Lshortfile)
	log.SetFlags(log.Lshortfile)

	vizList := ""
	vizHelp := "Visualize: all,none,useful"
	for flag := range Viz {
		vizHelp += "," + flag
	}

	flag.StringVar(&runBot, "b", "v8", "Which bot to run\n\t"+strings.Join(BotList(), "\n\t"))
	flag.StringVar(&vizList, "V", "", vizHelp)
	flag.IntVar(&debugLevel, "d", 0, "Debug level")
	flag.StringVar(&mapName, "m", "", "Map file -- Used to validate generated map, hill guessing etc.")
	flag.StringVar(&watchPoints, "w", "", "Watch points \"T1:[email protected],C,N[;T1:T2...]\", \":\" will watch everything")
	flag.IntVar(&maxTurn, "T", 65535, "Max Turn")
	flag.Parse()

	if BotGet(runBot) == nil {
		log.Printf("Unrecognized bot \"%s\", Registered bots:\n\t%s\n", runBot, strings.Join(BotList(), "\n\t"))
		return
	}

	SetWatcherPrefix(runBot)

	SetDebugLevel(debugLevel)
	SetViz(vizList, Viz)
}

示例#24
文件: boxcars.go 项目: lth2015/boxcars

func main() {
	flag.IntVar(&port, "port", 8080, "Port to listen")
	flag.BoolVar(&secure, "secure", false, "Enables secure mode to avoid running as sudo.")
	flag.IntVar(&user_id, "uid", 1000, "User id that'll own the system process.")
	flag.IntVar(&group_id, "gid", 1000, "Group id that'll own the system process.")
	flag.Parse()

	filename = flag.Arg(0)

	if filename == "" {
		fmt.Printf("Usage: boxcars config.json\n")
		os.Exit(1)
	}

	go func() {
		config := JSONConfig.NewJSONConfig(filename, boxcars.SetupSites)
		config.EnableAutoReload()
	}()

	if secure {
		go boxcars.Secure(user_id, group_id)
	}

	boxcars.Listen(port)
}

示例#25
文件: statsrelay.go 项目: denen99/statsrelay

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")
}

示例#26
文件: ats_config.go 项目: CadeLaRen/traffic_control

// getFlags parses and returns the command line arguments. The returned error
// will be non-nil if any expected arg is missing.
func getFlags() (Args, error) {
	var args Args
	flag.IntVar(&args.Port, "port", -1, "the port to serve on")
	flag.IntVar(&args.Port, "p", -1, "the port to serve on (shorthand)")
	flag.StringVar(&args.TrafficOpsUri, "uri", "", "the Traffic Ops URI")
	flag.StringVar(&args.TrafficOpsUri, "u", "", "the Traffic Ops URI (shorthand)")
	flag.StringVar(&args.TrafficOpsUser, "user", "", "the Traffic Ops username")
	flag.StringVar(&args.TrafficOpsUser, "U", "", "the Traffic Ops username (shorthand)")
	flag.StringVar(&args.TrafficOpsPass, "Pass", "", "the Traffic Ops password")
	flag.StringVar(&args.TrafficOpsPass, "P", "", "the Traffic Ops password (shorthand)")
	flag.Parse()
	if args.Port == -1 {
		return args, errors.New("Missing port")
	}
	if args.Port < 0 || args.Port > 65535 {
		return args, errors.New("Invalid port")
	}
	if args.TrafficOpsUri == "" {
		return args, errors.New("Missing CDN URI")
	}
	if args.TrafficOpsUser == "" {
		return args, errors.New("Missing CDN user")
	}
	if args.TrafficOpsPass == "" {
		return args, errors.New("Missing CDN password")
	}
	return args, nil
}

示例#27
文件: main.go 项目: schatt/skydns

func init() {
	flag.StringVar(&config.Domain, "domain", env("SKYDNS_DOMAIN", "skydns.local."), "domain to anchor requests to (SKYDNS_DOMAIN)")
	flag.StringVar(&config.DnsAddr, "addr", env("SKYDNS_ADDR", "127.0.0.1:53"), "ip:port to bind to (SKYDNS_ADDR)")
	flag.StringVar(&nameserver, "nameservers", env("SKYDNS_NAMESERVERS", ""), "nameserver address(es) to forward (non-local) queries to e.g. 8.8.8.8:53,8.8.4.4:53")
	flag.BoolVar(&config.NoRec, "no-rec", false, "do not provide a recursive service")
	flag.StringVar(&machine, "machines", env("ETCD_MACHINES", ""), "machine address(es) running etcd")
	flag.StringVar(&config.DNSSEC, "dnssec", "", "basename of DNSSEC key file e.q. Kskydns.local.+005+38250")
	flag.StringVar(&config.Local, "local", "", "optional unique value for this skydns instance")
	flag.StringVar(&tlskey, "tls-key", env("ETCD_TLSKEY", ""), "TLS Private Key path")
	flag.StringVar(&tlspem, "tls-pem", env("ETCD_TLSPEM", ""), "X509 Certificate")
	flag.StringVar(&cacert, "ca-cert", env("ETCD_CACERT", ""), "CA Certificate")
	flag.DurationVar(&config.ReadTimeout, "rtimeout", 2*time.Second, "read timeout")
	flag.BoolVar(&config.RoundRobin, "round-robin", true, "round robin A/AAAA replies")
	flag.BoolVar(&discover, "discover", false, "discover new machines by watching /v2/_etcd/machines")
	flag.BoolVar(&stub, "stubzones", false, "support stub zones")
	flag.BoolVar(&config.Verbose, "verbose", false, "log queries")
	flag.BoolVar(&config.Systemd, "systemd", false, "bind to socket(s) activated by systemd (ignore -addr)")

	// TTl
	// Minttl
	flag.StringVar(&config.Hostmaster, "hostmaster", "[email protected]", "hostmaster email address to use")
	flag.IntVar(&config.SCache, "scache", server.SCacheCapacity, "capacity of the signature cache")
	flag.IntVar(&config.RCache, "rcache", 0, "capacity of the response cache") // default to 0 for now
	flag.IntVar(&config.RCacheTtl, "rcache-ttl", server.RCacheTtl, "TTL of the response cache")

	flag.StringVar(&msg.PathPrefix, "path-prefix", env("SKYDNS_PATH_PREFIX", "skydns"), "backend(etcd) path prefix, default: skydns")
}

示例#28
文件: psort.go 项目: dreyk/dtests

func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())
	var port int
	var size int
	var criteria string
	var index string
	var elastic string
	flag.IntVar(&port, "p", 8080, "HTTP Port")
	flag.IntVar(&size, "s", 10, "LRU Size")
	flag.StringVar(&criteria, "c", "all-criteria", "Criteria File")
	flag.StringVar(&index, "i", "staging1_hotels_id", "Index")
	flag.StringVar(&elastic, "eaddr", "", "Eaddr")
	flag.Parse()
	var s *Sphere
	if elastic == "" {
		s = testSphere(criteria, 50000)
	} else {
		s = loadElastic(index, elastic, criteria)
	}
	cache = newCache(size, s)
	http.HandleFunc("/", httpHander)
	httpAddr := fmt.Sprintf(":%d", port)
	log.Println("Started on ", port)
	log.Fatal(http.ListenAndServe(httpAddr, nil))
}

示例#29
文件: flags.go 项目: JustinDrake/go-ethereum

func Init() {
	flag.Usage = func() {
		fmt.Fprintf(os.Stderr, "%s [options] [filename]:\noptions precedence: default < config file < environment variables < command line\n", os.Args[0])
		flag.PrintDefaults()
	}

	flag.StringVar(&Identifier, "id", "", "Custom client identifier")
	flag.StringVar(&KeyRing, "keyring", "", "identifier for keyring to use")
	flag.StringVar(&KeyStore, "keystore", "db", "system to store keyrings: db|file (db)")
	flag.StringVar(&OutboundPort, "port", "30303", "listening port")
	flag.BoolVar(&UseUPnP, "upnp", false, "enable UPnP support")
	flag.IntVar(&MaxPeer, "maxpeer", 10, "maximum desired peers")
	flag.IntVar(&RpcPort, "rpcport", 8080, "port to start json-rpc server on")
	flag.BoolVar(&StartRpc, "rpc", false, "start rpc server")
	flag.BoolVar(&NonInteractive, "y", false, "non-interactive mode (say yes to confirmations)")
	flag.BoolVar(&UseSeed, "seed", true, "seed peers")
	flag.BoolVar(&GenAddr, "genaddr", false, "create a new priv/pub key")
	flag.StringVar(&SecretFile, "import", "", "imports the file given (hex or mnemonic formats)")
	flag.StringVar(&ExportDir, "export", "", "exports the session keyring to files in the directory given")
	flag.StringVar(&LogFile, "logfile", "", "log file (defaults to standard output)")
	flag.StringVar(&Datadir, "datadir", defaultDataDir(), "specifies the datadir to use")
	flag.StringVar(&ConfigFile, "conf", defaultConfigFile, "config file")
	flag.StringVar(&DebugFile, "debug", "", "debug file (no debugging if not set)")
	flag.IntVar(&LogLevel, "loglevel", int(ethlog.InfoLevel), "loglevel: 0-5: silent,error,warn,info,debug,debug detail)")
	flag.BoolVar(&DiffTool, "difftool", false, "creates output for diff'ing. Sets LogLevel=0")
	flag.StringVar(&DiffType, "diff", "all", "sets the level of diff output [vm, all]. Has no effect if difftool=false")

	flag.BoolVar(&StartMining, "mine", false, "start dagger mining")
	flag.BoolVar(&StartJsConsole, "js", false, "launches javascript console")

	flag.Parse()

	InputFile = flag.Arg(0)
}

示例#30
文件: main.go 项目: s-vp/fluent-agent-hydra

func main() {
	var (
		forwardPort     int
		httpPort        int
		countInterval   int
		dir             string
		dumpIncludeTag  bool
		dumpIncludeTime bool
		dumpFileFormat  string
	)
	flag.IntVar(&forwardPort, "forward-port", 24224, "fluentd forward listen port")
	flag.IntVar(&httpPort, "http-port", 24225, "http listen port")
	flag.IntVar(&countInterval, "count-interval", 60, "log counter output interval(sec)")
	flag.StringVar(&dir, "dump-file-dir", "", "dump file directory")
	flag.BoolVar(&dumpIncludeTag, "dump-include-tag", false, "dump file include tag")
	flag.BoolVar(&dumpIncludeTime, "dump-include-time", false, "dump file include time")
	flag.StringVar(&dumpFileFormat, "dump-file-format", "json", "dump file format")
	flag.Parse()

	go runReporter(time.Duration(countInterval) * time.Second)
	if dir != "" {
		DumpCh = make(chan fluent.FluentRecordSet, MessageBufferLen)
		option := OutputOption{dumpIncludeTime, dumpIncludeTag}
		go runDumper(dir, dumpFileFormat, option)
	}
	var err error
	err = runForwardServer(forwardPort)
	if err != nil {
		log.Fatal(err)
	}
	err = runHTTPServer(httpPort)
	if err != nil {
		log.Fatal(err)
	}
}

展开阅读全文