Example #1
0
func init() {
	var b bytes.Buffer
	for name, s := range scalerByName {
		if s == vibrant.DefaultScaler {
			scalerName = name
		}
		if b.Len() > 0 {
			b.WriteString(", ")
		}
		b.WriteString(name)
	}
	availableScalers := b.String()

	flag.StringVar(&outputFile, "outputFile", "", "Output location for a quantized version of the image.")
	flag.StringVar(&outputFile, "o", outputFile, "Output location for a quantized version of the image.")

	flag.Uint64Var(&maximumColorCount, "maximumColorCount", maximumColorCount, "Maximum color count.")
	flag.Uint64Var(&maximumColorCount, "m", maximumColorCount, "Maximum color count.")

	flag.Uint64Var(&resizeImageArea, "resizeImageArea", resizeImageArea, "Resize image area.")
	flag.Uint64Var(&resizeImageArea, "r", resizeImageArea, "Resize image area.")

	flag.BoolVar(&debug, "debug", debug, "Debug mode.")
	flag.BoolVar(&debug, "d", debug, "Debug mode.")

	flag.StringVar(&scalerName, "scaler", scalerName, "Scaler.  One of: "+availableScalers)
	flag.StringVar(&scalerName, "s", scalerName, "Scaler.  One of: "+availableScalers)

	flag.Parse()

	inputFile = flag.Arg(0)
}
Example #2
0
func registerFlags() {
	flag.StringVar(&addressVersion, "address-version", addressVersion,
		"Network address version. Options are \"test\" and \"main\"")

	// Input files
	flag.StringVar(&blockchainFile, "blockchain", blockchainFile,
		"Location of the blockchain file")

	// Output files
	flag.StringVar(&transactionFileOut, "transaction-out", transactionFileOut,
		"Where to write the created transaction, if not committing to the "+
			"blockchain")

	// Ownership parameters. Some of these are mutually exclusive
	flag.StringVar(&srcWallet, "src-wallet", srcWallet,
		"Use this wallet as the spender")
	flag.IntVar(&srcWalletEntry, "src-wallet-entry", srcWalletEntry,
		"Only spend from this entry in the wallet. -1 means use all.")
	flag.StringVar(&srcSecretKey, "src-secret", srcSecretKey,
		"Spend from this secret key")

	// Spending destination
	flag.StringVar(&destAddress, "dest", destAddress,
		"Which address to send the coins to")

	// Spending amount options
	flag.Uint64Var(&spendCoins, "coins", spendCoins, "How many coins to spend")
	flag.Uint64Var(&spendHours, "hours", spendHours, "How many hours to spend")
	flag.Uint64Var(&spendFee, "fee", spendFee,
		"How much to pay in fee above the minimum fee")
	flag.Uint64Var(&burnFactor, "burn", burnFactor,
		"How many hours must be spent as a minimum fee, calculated as the "+
			"number of output hours divided by this number. 0 is no burn.")
}
Example #3
0
func FlagsParse() {
	flag.StringVar(&Port, "port", "50000", "node port")
	flag.StringVar(&Host, "host", "127.0.0.1", "node address")
	flag.Uint64Var(&MinWorkers, "minWorkers", 2, "min workers")
	flag.Uint64Var(&MinPartitionsPerWorker, "ppw", 1, "min partitions per worker")
	flag.Int64Var(&MessageThreshold, "mthresh", 1000, "message threshold")
	flag.Int64Var(&VertexThreshold, "vthresh", 1000, "vertex threshold")
	flag.StringVar(&LoadPath, "loadPath", "data", "data load path")
	flag.StringVar(&PersistPath, "persistPath", "persist", "data persist path")

	flag.Parse()
}
Example #4
0
//============================================================================
//		main : Entry point.
//----------------------------------------------------------------------------
func main() {

	var dwarfData *dwarf.Data
	var theFile *macho.File
	var theErr os.Error
	var relativeAddress uint64
	var runtimeAddress uint64
	var loadAddress uint64
	var segmentAddress uint64
	var pathMacho string
	var pathDsym string

	// Parse our arguments
	flag.Uint64Var(&runtimeAddress, "raddr", 0, "")
	flag.Uint64Var(&loadAddress, "laddr", 0, "")
	flag.StringVar(&pathMacho, "macho", "", "")
	flag.StringVar(&pathDsym, "dsym", "", "")
	flag.Parse()

	if runtimeAddress == 0 || loadAddress == 0 || pathMacho == "" || pathDsym == "" {
		printHelp()
	}

	// Find the text segment address
	theFile, theErr = macho.Open(pathMacho)
	if theErr != nil {
		fatalError("Can't open Mach-O file: " + theErr.String())
	}

	segmentAddress = theFile.Segment("__TEXT").Addr

	theFile.Close()

	// Calculate the target address
	relativeAddress = runtimeAddress - loadAddress
	gTargetAddress = segmentAddress + relativeAddress

	// Find the target
	theFile, theErr = macho.Open(pathDsym)
	if theErr != nil {
		fatalError("Can't open .dsym file: " + theErr.String())
	}

	dwarfData, theErr = theFile.DWARF()
	if theErr != nil {
		fatalError("Can't find DWARF info: " + theErr.String())
	}

	processChildren(dwarfData.Reader(), 0, false)

	theFile.Close()
}
Example #5
0
func init() {

	flag.Uint64Var(&CmdlineOptions.SpoolSize, "spool-size", CmdlineOptions.SpoolSize, "event count spool threshold - forces network flush")
	flag.Uint64Var(&CmdlineOptions.SpoolSize, "sv", CmdlineOptions.SpoolSize, "event count spool threshold - forces network flush")

	flag.IntVar(&CmdlineOptions.HarvesterBufferSize, "harvest-buffer-size", CmdlineOptions.HarvesterBufferSize, "harvester reader buffer size")
	flag.IntVar(&CmdlineOptions.HarvesterBufferSize, "hb", CmdlineOptions.HarvesterBufferSize, "harvester reader buffer size")

	flag.BoolVar(&CmdlineOptions.TailOnRotate, "tail", CmdlineOptions.TailOnRotate, "always tail on log rotation -note: may skip entries ")
	flag.BoolVar(&CmdlineOptions.TailOnRotate, "t", CmdlineOptions.TailOnRotate, "always tail on log rotation -note: may skip entries ")

	flag.BoolVar(&CmdlineOptions.Quiet, "quiet", CmdlineOptions.Quiet, "operate in quiet mode - only emit errors to log")
}
Example #6
0
func init() {
	flag.StringVar(&hostname, "hostname", "localhost:9092", "host:port string for the kafka server")
	flag.StringVar(&topic, "topic", "test", "topic to publish to")
	flag.StringVar(&partitionstr, "partitions", "0", "partitions to publish to:  comma delimited")
	flag.Uint64Var(&offset, "offset", 0, "offset to start consuming from")
	flag.UintVar(&maxSize, "maxsize", 1048576, "max size in bytes to consume a message set")
	flag.Uint64Var(&maxMsgCt, "msgct", math.MaxUint64, "max number of messages to read")
	flag.StringVar(&writePayloadsTo, "writeto", "", "write payloads to this file")
	flag.BoolVar(&consumerForever, "consumeforever", true, "loop forever consuming")
	flag.BoolVar(&printmessage, "print", true, "print the message details to stdout")
	log.SetOutput(os.Stdout)
	log.SetFlags(log.Ltime | log.Lshortfile)
}
Example #7
0
func init() {
	runtime.GOMAXPROCS(runtime.NumCPU())

	flag.StringVar(&common.URL, "url", "127.0.0.1:80", "<ipaddress:port> | default 127.0.0.1:80")
	flag.StringVar(&common.METHOD, "method", "GET", "<GET | POST | PUT | HEAD | PATCH | DELETE | OPTIONS | TRACE | CONNECT> | default GET")
	flag.StringVar(&common.HEADER, "header", "", "<'key: value, key: value'> | default none")
	flag.StringVar(&common.COOKIE, "cookie", "", "<'name=value;name=value'> | default none")
	flag.StringVar(&common.DATA, "data", "", "<'name=value;name=value'> | default none")

	flag.Uint64Var(&common.VCLIENT, "client", 10, "default 10")
	flag.Uint64Var(&common.VCLICK, "click", 10, "default 10")

	flag.Parse()
}
Example #8
0
/**
 * https://projecteuler.net/problem=3
 */
func main() {
	var natural_number uint64
	var largestPrimeFactor uint64

	flag.BoolVar(&debug, "debug", false, "Display verbose info")
	flag.Uint64Var(&natural_number, "number", uint64(0), "A number to find factors for")
	// now that all flags have been assigned, we can parse the CLI parameters
	flag.Parse()

	// make sure the CLI input is acceptable; if not error out with a helpful usage message
	if natural_number < uint64(1) {
		fmt.Println("You must pass in a number to factorize (Unsigned 64 integer)")
		return
	} else {
		if debug {
			fmt.Printf("factorizing this term: %d\n", natural_number)
		}
	}

	largestPrimeFactor = LargestPrimeFactor(natural_number)

	// spit out the answer.
	fmt.Printf("%d\n", largestPrimeFactor)

	return
}
Example #9
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")
}
Example #10
0
/**
 * https://projecteuler.net/problem=1
 */
func main() {
	var max_natural_number uint64
	var sum uint64
	var i uint64

	flag.Uint64Var(&max_natural_number, "max", uint64(0), "Maximum natural number")
	// now that all flags have been assigned, we can parse the CLI parameters
	flag.Parse()

	// make sure the CLI input is acceptable; if not error out with a helpful usage message
	if max_natural_number < uint64(1) {
		fmt.Println("You must pass in a a maximum (Unsigned 64 integer)")
		return
	} else {
		fmt.Printf("max_natural_number: %d\n", max_natural_number)
	}

	sum = 0
	for i = 1; i < max_natural_number; i++ {
		if i%3 == 0 || i%5 == 0 {
			fmt.Printf("multiple of 3 or 5: %d\n", i)
			sum += i
		}
	}

	// spit out the answer.
	fmt.Printf("%d\n", sum)

	return
}
Example #11
0
func init() {
	DefaultEnvironment = Environment{}
	flag.StringVar(&DefaultEnvironment.Port, "port", "", "The microservice port.")
	flag.StringVar(&DefaultEnvironment.Host, "host", "", "The microservice host.")
	flag.Uint64Var(&DefaultEnvironment.Frequency, "frequency", 10, "The frequency at which the service updates statuses.")
	flag.StringVar(&DefaultEnvironment.IntServiceURL, "int", "", "The internal service to service url.")
}
Example #12
0
func main() {
	config := config.Load()

	var chainID string
	var serverAddr string
	var windowSize uint64

	flag.StringVar(&serverAddr, "server", fmt.Sprintf("%s:%d", config.General.ListenAddress, config.General.ListenPort), "The RPC server to connect to.")
	flag.StringVar(&chainID, "chainID", provisional.TestChainID, "The chain ID to deliver from.")
	flag.Uint64Var(&windowSize, "windowSize", 10, "The window size for the deliver.")
	flag.Parse()

	conn, err := grpc.Dial(serverAddr, grpc.WithInsecure())
	if err != nil {
		fmt.Println("Error connecting:", err)
		return
	}
	client, err := ab.NewAtomicBroadcastClient(conn).Deliver(context.TODO())
	if err != nil {
		fmt.Println("Error connecting:", err)
		return
	}

	s := newDeliverClient(client, chainID, windowSize)
	s.seekOldest()
	s.readUntilClose()

}
Example #13
0
func main() {
	flag.StringVar(&addr, "addr", "127.0.0.1:80", "bitcask http listen addr")
	flag.StringVar(&storagePath, "s", "bitcaskStorage", "data storage path")
	flag.Uint64Var(&maxSize, "ms", 1<<32, "single data file maxsize")
	flag.IntVar(&logLevel, "l", 0, "logger level")
	flag.Parse()

	logger.SetLevel(1)
	opts := &bitcask.Options{
		MaxFileSize: maxSize,
	}
	var err error
	bc, err = bitcask.Open(storagePath, opts)
	if err != nil {
		logger.Fatal(err)
	}
	defer bc.Close()

	defer func() {
		if err := recover(); err != nil {
			logger.Error(err)
			debug.PrintStack()
		}
	}()

	r := mux.NewRouter()
	r.HandleFunc("/{key}", bitcaskGetHandle).Methods("GET")
	r.HandleFunc("/{key}", bitcaskDelHandle).Methods("DELETE")
	r.HandleFunc("/{key}", bitcaskPutHandle).Methods("POST")
	logger.Info("bitcask server listen:", addr)
	if err := http.ListenAndServe(addr, r); err != nil {
		logger.Error(err)
	}
}
Example #14
0
File: qrpc.go Project: kuba--/qrpc
func main() {
	log.SetFlags(log.LstdFlags | log.Lshortfile)

	flag.IntVar(&cfg.Port, "port", 9033, "port to listen on")
	flag.StringVar(&cfg.DataBasePath, "data", "/tmp/qrpc", "directory in which queue data is stored")
	flag.Uint64Var(&cfg.MaxCacheSize, "cache", 1024*1024, "max. cache size (bytes) before an item is evicted.")
	flag.DurationVar(&cfg.ClusterRequestTimeout, "timeout", 3*time.Second, "cluster request (gossip) timeout.")
	flag.DurationVar(&cfg.ClusterWatchInterval, "interval", time.Second, "cluster watch timer interval.")
	flag.Usage = func() {
		fmt.Fprintf(os.Stderr, "usage: %s [flags] [cluster peer(s) ...]\n", os.Args[0])
		fmt.Fprintln(os.Stderr, "flags:")
		flag.PrintDefaults()
		os.Exit(2)
	}
	flag.Parse()
	cfg.ClusterPeers = flag.Args()

	s := qrpc.NewServer(&cfg)
	errchan := s.Start()

	// Handle SIGINT and SIGTERM.
	sigchan := make(chan os.Signal, 1)
	signal.Notify(sigchan, os.Interrupt, os.Kill)

	select {
	case sig := <-sigchan:
		log.Printf("Signal %s received, shutting down...\n", sig)
		s.Stop()

	case err := <-errchan:
		log.Fatalln(err)
	}
}
Example #15
0
func init() {
	flag.StringVar(&colorScheme, "color", "heat", "how to render the magnitudes (grayscale, rainbow)")
	flag.StringVar(&scaleType, "scale", "linear", "the scale to use for the x/value axis (linear, logarithmic, exponential)")
	flag.Float64Var(&maximumValue, "maximum", 0, "allows you to specify the expected maximum value to avoid rendering interruptions")
	flag.Uint64Var(&maximumMagnitude, "magnitude", 0, "allows you to specify the expected maximum magnitude value (i.e. frequency, which depends on the width of the summarisation buckets) to avoid rendering interruptions")
	flag.UintVar(&msBetweenSamples, "sample-period-ms", defaultMsBetweenSamples, "controls the minimum amount of milliseconds between samples")
	flag.Parse()

	switch colorScheme {
	case "grayscale":
		colorScale = grayScale
	case "rainbow":
		colorScale = rainbowScale
	case "heat":
		colorScale = heatScale
	default:
		fmt.Fprintln(os.Stderr, "Did not recognise color scheme specified. Must be one of grayscale, rainbow, heat")
		os.Exit(1)
	}
	switch scaleType {
	case "logarithmic":
		scale = logarithmicScale // higher resolution of higher numbers
		reverseScale = reverseLogarithmicScale
	case "exponential":
		scale = exponentialScale // higher resolution of small numbers
		reverseScale = reverseExponentialScale
	case "linear":
		scale = linearScale // uniform resolution
		reverseScale = reverseLinearScale
	default:
		fmt.Fprintln(os.Stderr, "Did not recognise scale provided. Must be one of linear, logarithmic, exponential")
		os.Exit(2)
	}

}
Example #16
0
File: main.go Project: cj123/rover
func init() {
	flag.StringVar(&sourceURL, "u", "", "the url you wish to download from")
	flag.StringVar(&remoteFile, "r", "", "the remote filename to download")
	flag.StringVar(&localFile, "o", "", "the output filename")
	flag.IntVar(&timeout, "t", 5, "timeout, in seconds")
	flag.BoolVar(&verbose, "v", false, "verbose")
	flag.BoolVar(&showFiles, "l", false, "list files in zip")
	flag.Uint64Var(&limitBytes, "b", 0, "limit filesize downloaded (in bytes)")

	flag.Parse()

	if sourceURL == "" {
		fmt.Println("You must specify a URL")
		flag.PrintDefaults()
		os.Exit(1)
	}

	if !showFiles {
		if remoteFile == "" {
			fmt.Println("You must specify a remote filename")
			flag.PrintDefaults()
			os.Exit(1)
		}

		if localFile == "" {
			_, localFile = filepath.Split(remoteFile)
		}
	}
}
Example #17
0
// Builds a conf data structure and connects
// the fields in the struct to flags.
// It is up to the caller to call flag.Parse()
func New() *D {
	d := new(D)

	flag.BoolVar(&d.PrintVersion, "version", false,
		"Print l2met version and sha.")

	flag.StringVar(&d.AppName, "app-name", "l2met",
		"Prefix internal log messages with this value.")

	flag.IntVar(&d.BufferSize, "buffer", 1024,
		"Max number of items for all internal buffers.")

	flag.IntVar(&d.Concurrency, "concurrency", 10,
		"Number of running go routines for outlet or receiver.")

	flag.IntVar(&d.Port, "port", 8080,
		"HTTP server's bind port.")

	flag.IntVar(&d.OutletRetries, "outlet-retry", 2,
		"Number of attempts to outlet metrics to Librato.")

	flag.Int64Var(&d.ReceiverDeadline, "recv-deadline", 2,
		"Number of time units to pass before dropping incoming logs.")

	flag.DurationVar(&d.OutletTtl, "outlet-ttl", time.Second*2,
		"Timeout set on Librato HTTP requests.")

	flag.Uint64Var(&d.MaxPartitions, "partitions", uint64(1),
		"Number of partitions to use for outlets.")

	flag.DurationVar(&d.FlushInterval, "flush-interval", time.Second,
		"Time to wait before sending data to store or outlet. "+
			"Example:60s 30s 1m")

	flag.DurationVar(&d.OutletInterval, "outlet-interval", time.Second,
		"Time to wait before outlets read buckets from the store. "+
			"Example:60s 30s 1m")

	flag.BoolVar(&d.UseOutlet, "outlet", false,
		"Start the Librato outlet.")

	flag.BoolVar(&d.UsingReciever, "receiver", false,
		"Enable the Receiver.")

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

	d.RedisHost, d.RedisPass, _ = parseRedisUrl(env("REDIS_URL"))
	d.Secrets = strings.Split(mustenv("SECRETS"), ":")

	if len(env("METCHAN_URL")) > 0 {
		url, err := url.Parse(env("METCHAN_URL"))
		if err == nil {
			d.MetchanUrl = url
		}
	}

	return d
}
Example #18
0
File: config.go Project: hqr/surge
func RegisterCmdlineUint64Var(dest *uint64, opt string, def uint64, desc string) bool {
	if flag.Parsed() {
		return false
	}
	flag.Uint64Var(dest, opt, def, desc)

	return true
}
Example #19
0
func init() {
	flag.Uint64Var(&users, "u", 10, "concurrent users.")
	flag.StringVar(&timeout, "t", "30s",
		"duration for performing transactions. Use s, m, h modifiers")
	flag.StringVar(&output, "o", "", "output file for summary")
	flag.StringVar(&configfile, "c", "conquest.js", "conquest js file path")
	flag.BoolVar(&sequential, "s", false, "do transactions in sequential mode")
	flag.BoolVar(&verbose, "v", false, "print failed requests")
}
Example #20
0
File: fbapp.go Project: stoyan/rell
// Defines flags to configure an application.
func Flag(name string) App {
	app := &app{}
	flag.Uint64Var(&app.id, name+".id", 0, "Facebook application ID.")
	flag.StringVar(
		&app.secret, name+".secret", "", "Facebook application secret.")
	flag.StringVar(
		&app.namespace, name+".namespace", "", "Facebook application namespace.")
	return app
}
Example #21
0
/**
 * https://projecteuler.net/problem=2
 */
func main() {
	var max_natural_number uint64
	var sum uint64
	var i uint64
	var prev, curr, next uint64
	var debug bool

	flag.BoolVar(&debug, "debug", false, "Display verbose info")
	flag.Uint64Var(&max_natural_number, "max", uint64(0), "Maximum natural number")
	// now that all flags have been assigned, we can parse the CLI parameters
	flag.Parse()

	// make sure the CLI input is acceptable; if not error out with a helpful usage message
	if max_natural_number < uint64(1) {
		fmt.Println("You must pass in a maximum (Unsigned 64 integer)")
		return
	} else {
		if debug {
			fmt.Printf("maximum term: %d\n", max_natural_number)
		}
	}

	prev = uint64(1)
	if debug {
		fmt.Printf("1: %d\n", prev)
	}
	curr = uint64(2)
	if debug {
		fmt.Printf("2: %d\n", curr)
	}
	sum = prev + curr
	// we have hard-coded terms 1 and 2.  Start the programmatic arithmatic with term 3
	for i = 3; curr <= max_natural_number; i++ {
		next = prev + curr
		if next > max_natural_number {
			break
		}
		if next%2 == 0 {
			if debug {
				fmt.Printf("%d: %d (+)\n", i, next)
			}
			sum += next
		} else {
			if debug {
				fmt.Printf("%d: %d\n", i, next)
			}
		}
		prev = curr
		curr = next
	}

	// spit out the answer.
	fmt.Printf("%d\n", sum)

	return
}
Example #22
0
func init() {
	flag.StringVar(&hostname, "hostname", "localhost:9092", "host:port string for the kafka server")
	flag.StringVar(&topic, "topic", "test", "topic to publish to")
	flag.IntVar(&partition, "partition", 0, "partition to publish to")
	flag.Uint64Var(&offset, "offset", 0, "offset to start consuming from")
	flag.UintVar(&maxSize, "maxsize", 1048576, "max size in bytes of message set to request")
	flag.StringVar(&writePayloadsTo, "writeto", "", "write payloads to this file")
	flag.BoolVar(&consumerForever, "consumeforever", false, "loop forever consuming")
	flag.BoolVar(&printmessage, "printmessage", true, "print the message details to stdout")
}
func init() {
	flag.StringVar(&options.configArg, "config", options.configArg, "path to logstash-forwarder configuration file or directory")

	flag.StringVar(&options.cpuProfileFile, "cpuprofile", options.cpuProfileFile, "path to cpu profile output - note: exits on profile end.")

	flag.Uint64Var(&options.spoolSize, "spool-size", options.spoolSize, "event count spool threshold - forces network flush")
	flag.Uint64Var(&options.spoolSize, "sv", options.spoolSize, "event count spool threshold - forces network flush")

	flag.IntVar(&options.harvesterBufferSize, "harvest-buffer-size", options.harvesterBufferSize, "harvester reader buffer size")
	flag.IntVar(&options.harvesterBufferSize, "hb", options.harvesterBufferSize, "harvester reader buffer size")

	flag.BoolVar(&options.useSyslog, "log-to-syslog", options.useSyslog, "log to syslog instead of stdout") // deprecate this
	flag.BoolVar(&options.useSyslog, "syslog", options.useSyslog, "log to syslog instead of stdout")

	flag.BoolVar(&options.tailOnRotate, "tail", options.tailOnRotate, "always tail on log rotation -note: may skip entries ")
	flag.BoolVar(&options.tailOnRotate, "t", options.tailOnRotate, "always tail on log rotation -note: may skip entries ")

	flag.BoolVar(&options.quiet, "quiet", options.quiet, "operate in quiet mode - only emit errors to log")
	flag.BoolVar(&options.version, "version", options.version, "output the version of this program")
}
Example #24
0
func init() {
	flag.IntVar(&taskOption.ContextId, "glow.flow.id", -1, "flow id")
	flag.IntVar(&taskOption.TaskGroupId, "glow.taskGroup.id", -1, "task group id")
	flag.StringVar(&taskOption.FistTaskName, "glow.task.name", "", "name of first task in the task group")
	flag.StringVar(&taskOption.Inputs, "glow.taskGroup.inputs", "", "comma and @ seperated input locations")
	flag.StringVar(&taskOption.ExecutableFileHash, "glow.exe.hash", "", "hash of executable binary file")
	flag.IntVar(&taskOption.ChannelBufferSize, "glow.channel.bufferSize", 0, "channel buffer size for reading inputs")
	flag.Uint64Var(&taskOption.RequestId, "glow.request.id", 0, "request id received from agent")

	flow.RegisterTaskRunner(NewTaskRunner(&taskOption))
}
Example #25
0
func init() {
	flag.StringVar(&ds, "dbs", "", "Comma-delimited list of databases to convert. Default is to convert all databases.")
	flag.Uint64Var(&tsmSz, "sz", maxTSMSz, "Maximum size of individual TSM files.")
	flag.BoolVar(&parallel, "parallel", false, "Perform parallel conversion.")
	flag.BoolVar(&disBack, "nobackup", false, "Disable database backups. Not recommended.")
	flag.Usage = func() {
		fmt.Fprintf(os.Stderr, "Usage: %s [options] <data-path> \n", os.Args[0])
		fmt.Fprintf(os.Stderr, "%s\n\n", description)
		flag.PrintDefaults()
		fmt.Fprintf(os.Stderr, "\n")
	}
}
Example #26
0
/**
 * https://projecteuler.net/problem=3
 */
func main() {
	var natural_number uint64
	var lowest_common_demoninator uint64
	var allFactors map[uint64]uint64
	var theseFactors map[uint64]uint64

	flag.BoolVar(&debug, "debug", false, "Display verbose info")
	flag.Uint64Var(&natural_number, "number", uint64(0), "A number to find factors for")
	// now that all flags have been assigned, we can parse the CLI parameters
	flag.Parse()

	// make sure the CLI input is acceptable; if not error out with a helpful usage message
	if natural_number < uint64(1) {
		fmt.Println("You must pass in a number to factorize (Unsigned 64 integer)")
		return
	} else {
		if debug {
			fmt.Printf("factorizing terms: 1 .. %d\n", natural_number)
		}
	}

	allFactors = make(map[uint64]uint64)
	lowest_common_demoninator = uint64(1)
	for i := uint64(2); i < natural_number; i++ {
		if debug {
			fmt.Printf("factorizing this term: %d\n", i)
		}
		theseFactors = factor.Factorize(i)
		for key, val := range theseFactors {
			if debug {
				fmt.Printf("%d => %d\n", key, val)
			}
			if theseFactors[key] > allFactors[key] {
				allFactors[key] = theseFactors[key]
			}
		}
	}

	for key, val := range allFactors {
		if debug {
			fmt.Printf("%d => %d\n", key, val)
		}
		for j := 0; uint64(j) < val; j++ {
			lowest_common_demoninator *= key
		}
	}

	// spit out the answer.
	fmt.Printf("%d\n", lowest_common_demoninator)

	return
}
Example #27
0
func init() {
	config = Config{}
	c := &config
	flag.StringVar(&c.Addr, "address", "0.0.0.0:80",
		"Address to listen on: \"host:port\" where host and port can be names or numbers.")
	flag.StringVar(&c.Path, "path", "/dev/stdin",
		"Path to a source fifo, or a directory containing source fifos mapped onto the URI namespace.")
	flag.BoolVar(&c.ExecFlag, "exec", false,
		"Execute a command (given after all flags) and read from its stdout.")
	flag.Uint64Var(&c.FrameBytes, "frame-bytes", 64,
		"Size of a data frame. Only complete frames are sent to clients.")
	flag.StringVar(&c.FrameFilter, "frame-filter", "",
		"Detect frame boundaries in source streams and send only full frames to clients. When -frame-filter is active, -frame-bytes is the maximum frame size. Supported filter: mp3")
	flag.Uint64Var(&c.HeaderBytes, "header-bytes", 0,
		"Size of header. A header is read from each source when it is opened, and delivered to each client before sending any data bytes.")
	flag.Uint64Var(&c.SourceBuffer, "source-buffer", 64,
		"Number of frames to keep in memory for each source. The smaller this buffer is, the sooner a slow client will miss frames.")
	flag.Uint64Var(&c.SourceBandwidth, "source-bandwidth", 0,
		"Maximum bandwidth for each source, in bytes per second. 0=unlimited.")
	flag.Uint64Var(&c.ClientMaxBytes, "client-max-bytes", 0,
		"Maximum bytes to send to each client. 0=unlimited.")
	flag.BoolVar(&c.CloseIdle, "close-idle", false,
		"Close an input FIFO if all of its clients disconnect. This stops whatever process is writing to the FIFO, which can be useful if that process consumes resources, but depends on that process to restart/resume reliably. The FIFO will reopen next time a client requests it.")
	flag.StringVar(&c.ContentType, "content-type", "application/octet-stream",
		"Content-Type header for HTTP responses.")
	flag.IntVar(&c.CPUMax, "cpu-max", runtime.NumCPU(),
		"Maximum OS procs/threads to use. This effectively limits CPU consumption to the given number of cores. The default is the number of CPUs reported by the system. If 0 is given, the default is used.")
	flag.BoolVar(&c.Reopen, "reopen", true,
		"Reopen and resume reading if an error is encountered while reading an input FIFO. Default is true. Use -reopen=false to disable.")
	flag.DurationVar(&c.StatLogInterval, "stat-log-interval", 0,
		"Time between periodic statistics logs for each stream source, or 0 to disable.")
	flag.DurationVar(&c.MaxQuietInterval, "max-quiet-interval", 0,
		"Maximum time to wait for the next source frame before killing/closing/reopening the source, or 0 for unlimited.")
	flag.IntVar(&c.UID, "uid", os.Getuid(),
		"Setuid() to the given user after binding the listening port. (Ignored if 0. In Linux, use setcap instead.)")
	flag.BoolVar(&Debugging, "debug", false,
		"Print debug info.")
}
Example #28
0
func main() {
	zks := flag.String("zk", "127.0.0.1:2181,127.0.0.1:2182", "zookeeper servers")
	root := flag.String("root", "mycluster", "zookeeper root path")
	numOfNodes := flag.Uint("nsize", 128, "cluster virtual node size, default 128")
	flag.Uint64Var(&nodeDowntime, "downtime", 30, "erase cluster node after downtime(secs)")
	flag.Uint64Var(&nodeUptime, "uptime", 10, "add cluster node after uptime(secs)")
	flag.Parse()
	defer glog.Flush()

	zkAcls = zk.WorldACL(zk.PermAll)

	zkServers := strings.Split(*zks, ",")
	c, _, err := zk.Connect(zkServers, time.Second*10)
	if nil != err {
		glog.Errorf("Connect %v failed with reason:%v", zkServers, err)
		return
	}
	rootZkPath = "/" + *root
	serversZkPath = rootZkPath + "/servers"
	topoNodesPath = rootZkPath + "/topo/nodes"
	topoPartitionsPath = rootZkPath + "/topo/partitions"
	c.Create(rootZkPath, nil, 0, zkAcls)

	lock := zk.NewLock(c, rootZkPath+"/lock", zkAcls)
	err = lock.Lock()
	if nil != err {
		glog.Errorf("Lock failed with reason:%v", err)
		return
	}
	defer lock.Unlock()
	c.Create(serversZkPath, nil, 0, zkAcls)
	c.Create(rootZkPath+"/topo", nil, 0, zkAcls)
	c.Create(topoNodesPath, nil, 0, zkAcls)
	c.Create(topoPartitionsPath, nil, 0, zkAcls)
	zconn = c
	consitent = ssf.NewConsistent(int(*numOfNodes))
	watchdogProcess()
}
Example #29
0
// The flags will change the global singleton
func registerConnFlags(connParams *sqldb.ConnParams, name string) {
	flag.StringVar(&connParams.Host, "db-config-"+name+"-host", "", "db "+name+" connection host")
	flag.IntVar(&connParams.Port, "db-config-"+name+"-port", 0, "db "+name+" connection port")
	flag.StringVar(&connParams.Uname, "db-config-"+name+"-uname", "", "db "+name+" connection uname")
	flag.StringVar(&connParams.Pass, "db-config-"+name+"-pass", "", "db "+name+" connection pass")
	flag.StringVar(&connParams.DbName, "db-config-"+name+"-dbname", "", "db "+name+" connection dbname")
	flag.StringVar(&connParams.UnixSocket, "db-config-"+name+"-unixsocket", "", "db "+name+" connection unix socket")
	flag.StringVar(&connParams.Charset, "db-config-"+name+"-charset", "", "db "+name+" connection charset")
	flag.Uint64Var(&connParams.Flags, "db-config-"+name+"-flags", 0, "db "+name+" connection flags")
	flag.StringVar(&connParams.SslCa, "db-config-"+name+"-ssl-ca", "", "db "+name+" connection ssl ca")
	flag.StringVar(&connParams.SslCaPath, "db-config-"+name+"-ssl-ca-path", "", "db "+name+" connection ssl ca path")
	flag.StringVar(&connParams.SslCert, "db-config-"+name+"-ssl-cert", "", "db "+name+" connection ssl certificate")
	flag.StringVar(&connParams.SslKey, "db-config-"+name+"-ssl-key", "", "db "+name+" connection ssl key")
}
Example #30
0
func main() {
	default_dir := "dist"
	default_port, err := strconv.ParseUint(os.Getenv("PORT"), 0, 16)
	if err != nil {
		default_port = 5000
	}
	flag.StringVar(&file_dir, "f", default_dir, "Path to static file directory")
	flag.Uint64Var(&port, "p", default_port, "Port to serve on")
	flag.Parse()

	http.Handle("/", http.FileServer(http.Dir(file_dir)))
	log.Println(fmt.Sprintf("Serving at localhost:%d...", port))
	log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", port), nil))
}