Пример #1
0
func init() {
	flag.StringVar(&Package, "p", "atomap", "package name")
	flag.StringVar(&Key, "k", "int", "key type")
	flag.StringVar(&Value, "v", "int", "value type")
	flag.StringVar(&File, "f", "atomap.go", "file name")
	flag.Parse()
}
Пример #2
0
func main() {
	var bindAddress string
	var port int

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

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

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

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

	flag.Parse()

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

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

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

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

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

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

	log.Printf("Normal shutdown.\n")
}
Пример #3
0
func init() {
	flag.IntVar(&N, "N", 100, "Matrix rows/cols.")

	// blocking size; 0 is unblocked versions
	flag.IntVar(&KB, "KB", 0, "Blocking size for blocked invocations")

	// parameters for basic matrix operations
	flag.IntVar(&MB, "MB", 68, "Row blocking size.")
	flag.IntVar(&NB, "NB", 68, "Column blocking size.")
	flag.IntVar(&VPsize, "H", 68, "Viewport size.")
	flag.IntVar(&nWorker, "W", 2, "Number of workers for parallel runs")

	flag.BoolVar(&singleTest, "s", false, "Run single test run for given matrix size.")
	flag.BoolVar(&refTest, "r", false, "Test with lapack reference function.")
	flag.StringVar(&sizeList, "L", "", "Comma separated list of matrix sizes.")
	flag.IntVar(&testCount, "n", 5, "Number of test runs.")

	flag.BoolVar(&noSPD, "-nP", false, "Matrix is not SPD.")
	flag.BoolVar(&testUpper, "U", false, "Matrix is UPPER triangular. ")
	flag.BoolVar(&check, "C", false, "Check result against lapack reference.")
	flag.BoolVar(&verbose, "v", false, "Be verbose.")
	flag.BoolVar(&asGflops, "g", false, "Report as Gflops.")
	flag.BoolVar(&asEps, "e", false, "Report as result elements per seconds.")
	flag.StringVar(&testName, "T", "test", "Test name for reporting")
	flag.StringVar(&fileName, "F", "saved.dat", "Filename for source data")
}
Пример #4
0
func main() {
	var url, origin string
	flag.StringVar(&url, "url", "ws://127.0.0.1:9999/echo", "websocket URL")
	flag.StringVar(&origin, "origin", "http://localhost/", "origin header")
	flag.Parse()

	if url == "" {
		flag.Usage()
		os.Exit(1)
	}

	ws, err := websocket.Dial(url, "", origin)
	if err != nil {
		log.Fatal(err)
	}

	go func() {
		var msg = make([]byte, 512)
		for {
			n, err := ws.Read(msg)
			if err != nil {
				log.Fatal(err)
			}
			fmt.Printf("R: %s\nS: ", msg[:n])
		}
	}()

	fmt.Print("S: ")
	sc := bufio.NewScanner(os.Stdin)
	for sc.Scan() {
		if _, err := ws.Write(sc.Bytes()); err != nil {
			log.Fatal(err)
		}
	}
}
Пример #5
0
func main() {
	flag.StringVar(&url, "u", "", "URL to load test (required)")
	flag.StringVar(&method, "m", "GET", "HTTP method")
	flag.UintVar(&concurrency, "c", 10, "number of concurrent requests")
	flag.UintVar(&requests, "n", 1000, "number of total requests to make")
	flag.UintVar(&timeout, "t", 15, "request timeout in seconds")
	flag.StringVar(&regions, "r", "us-east-1,eu-west-1,ap-northeast-1", "AWS regions to run in (comma separated, no spaces)")
	flag.Parse()

	if url == "" {
		flag.Usage()
		os.Exit(0)
	}

	test, testerr := goad.NewTest(&goad.TestConfig{
		URL:            url,
		Concurrency:    concurrency,
		TotalRequests:  requests,
		RequestTimeout: time.Duration(timeout) * time.Second,
		Regions:        strings.Split(regions, ","),
		Method:         method,
	})
	if testerr != nil {
		fmt.Println(testerr)
		os.Exit(1)
	}

	var finalResult queue.RegionsAggData
	defer printSummary(&finalResult)

	sigChan := make(chan os.Signal, 1)
	signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM) // but interrupts from kbd are blocked by termbox

	start(test, &finalResult, sigChan)
}
Пример #6
0
// Main method.
func main() {
	conf := config.New()

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

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

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

	controller := handlers.NewController(conf, client, os.Stdout, os.Stderr, os.Stdin)
	controller.Add(handlers.NewLsHandler(controller))
	controller.Add(handlers.NewSetHandler(controller))
	controller.Add(handlers.NewHelpHandler(controller))
	controller.Add(handlers.NewCdHandler(controller))
	controller.Add(handlers.NewGetHandler(controller))
	os.Exit(controller.Start())
}
Пример #7
0
func New() {
	RootDir = findWorkingDir()

	flag.StringVar(&ApplicationBind, "bind", "localhost:8090", "Host and port to bind to")

	//TODO(kt): handle windows configuration dir
	defaultDataDir := fmt.Sprintf(path.Join(os.Getenv("HOME"), ".config", "sufr", "data"))
	flag.StringVar(&DataDir, "data-dir", defaultDataDir, "Location to store data in")

	defaultTemplateDir := path.Join(RootDir, "templates")
	flag.StringVar(&TemplateDir, "template-dir", defaultTemplateDir, "Location where templates are stored")

	defaultStaticDir := path.Join(RootDir, "static")
	flag.StringVar(&StaticDir, "static-dir", defaultStaticDir, "Location where static assets are stored")

	flag.BoolVar(&Debug, "debug", false, "Turn debugging on")

	flag.Parse()

	if _, err := os.Stat(DataDir); err != nil {
		if os.IsNotExist(err) {
			err := os.MkdirAll(DataDir, os.ModePerm)
			if err != nil {
				panic(err)
			}
		} else {
			panic(err)
		}
	}

	DatabaseFile = path.Join(DataDir, DatabaseName)
}
Пример #8
0
func main() {
	// options
	var bind, backend, logTo string
	var buffer uint
	var daemon bool
	flag.StringVar(&bind, "bind", ":8002", "locate ip and port")
	flag.StringVar(&backend, "backend", "127.0.0.1:8003", "backend server ip and port")
	flag.StringVar(&logTo, "logTo", "stdout", "stdout or syslog")
	flag.UintVar(&buffer, "buffer", 4096, "buffer size")
	flag.BoolVar(&daemon, "daemon", false, "run as daemon process")
	flag.Parse()

	log.SetOutput(os.Stdout)
	if logTo == "syslog" {
		w, err := syslog.New(syslog.LOG_INFO, "portproxy")
		if err != nil {
			log.Fatal(err)
		}
		log.SetOutput(w)
	}

	if daemon == true {
		godaemon.MakeDaemon(&godaemon.DaemonAttr{})
	}

	p := New(bind, backend, uint32(buffer))
	log.Println("portproxy started.")
	go p.Start()
	waitSignal()
}
Пример #9
0
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))
}
func init() {
	flag.StringVar(&RemoteAddress, "remote", "", "")
	flag.StringVar(&RemoteAddress, "r", "", "")

	flag.StringVar(&ServerAddress, "server", "", "")
	flag.StringVar(&ServerAddress, "s", "", "")
}
Пример #11
0
func init() {
	flag.BoolVar(&mainInstance.flags.verbose, "verbose", false, "Add verbose log to stderr")
	flag.StringVar(&mainInstance.flags.verboseFile, "verbosefile", "", "Will verbose log to a filename rather than stderr")
	flag.IntVar(&mainInstance.flags.chunkSize, "chunksize", 250, "size to chunk xargs into")
	flag.StringVar(&mainInstance.flags.filenamePrefix, "filename_prefix", "", "Prefix to append to all generated files")
	flag.BoolVar(&mainInstance.flags.forceAbs, "abs", false, "will force abs paths for ... dirs")
}
Пример #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()

}
Пример #13
0
// Makes a request for object using CloudFront cookie signing, and outputs
// the contents of the object to stdout.
//
// Usage example:
// signCookies -file <privkey file>  -id <keyId> -r <resource pattern> -g <object to get>
func main() {
	var keyFile string  // Private key PEM file
	var keyID string    // Key pair ID of CloudFront key pair
	var resource string // CloudFront resource pattern
	var object string   // S3 object frontented by CloudFront

	flag.StringVar(&keyFile, "file", "", "private key file")
	flag.StringVar(&keyID, "id", "", "key pair id")
	flag.StringVar(&resource, "r", "", "resource to request")
	flag.StringVar(&object, "g", "", "object to get")
	flag.Parse()

	// Load the PEM file into memory so it can be used by the signer
	privKey, err := sign.LoadPEMPrivKeyFile(keyFile)
	if err != nil {
		fmt.Println("failed to load key,", err)
		return
	}

	// Create the new CookieSigner to get signed cookies for CloudFront
	// resource requests
	signer := sign.NewCookieSigner(keyID, privKey)

	// Get the cookies for the resource. These will be used
	// to make the requests with
	cookies, err := signer.Sign(resource, time.Now().Add(1*time.Hour))
	if err != nil {
		fmt.Println("failed to sign cookies", err)
		return
	}

	// Use the cookies in a http.Client to show how they allow the client
	// to request resources from CloudFront.
	req, err := http.NewRequest("GET", object, nil)
	fmt.Println("Cookies:")
	for _, c := range cookies {
		fmt.Printf("%s=%s;\n", c.Name, c.Value)
		req.AddCookie(c)
	}

	// Send and handle the response. For a successful response the object's
	// content will be written to stdout. The same process could be applied
	// to a http service written cookies to the response but using
	// http.SetCookie(w, c,) on the ResponseWriter.
	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		fmt.Println("failed to send request", err)
		return
	}
	defer resp.Body.Close()

	b, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		fmt.Println("failed to read requested body", err)
		return
	}

	fmt.Println("Response:", resp.Status)
	fmt.Println(string(b))
}
Пример #14
0
func argParse() {
	flag.StringVar(&options.expr, "expr", "",
		"Specify input file or arithmetic expression string")
	flag.StringVar(&options.json, "json", "",
		"Specify input file or json string")
	flag.Parse()
}
Пример #15
0
func init() {
	flag.IntVar(&port, "port", 5038, "AMI port")
	flag.StringVar(&host, "host", "localhost", "AMI host")
	flag.StringVar(&user, "user", "admin", "AMI user")
	flag.StringVar(&password, "password", "admin", "AMI secret")
	flag.Parse()
}
Пример #16
0
func main() {
	// parse command line args
	flag.StringVar(&HookfilePath, "file", "config.json", "load hookfile")
	flag.BoolVar(&Debug, "debug", false, "print program debug messages")
	flag.StringVar(&ListenInterface, "interface", "0.0.0.0", "listen interface")
	flag.IntVar(&ListenPort, "port", 8000, "listen TCP port")
	flag.Parse()

	if HookfilePath == "" {
		eprintf("No configuration file specified\n")
		os.Exit(1)
	}

	// load config
	hookfile, err := LoadConfig(HookfilePath)
	if err != nil {
		panic(err)
	}

	rules = hookfile.Rules

	// configure routes
	http.HandleFunc("/", HandleHookRequest)

	// listen
	addr := fmt.Sprintf("%s:%d", ListenInterface, ListenPort)
	printf("starting server on %s\n", addr)
	err = http.ListenAndServe(addr, nil)
	if err != nil {
		panic(err)
	}
}
Пример #17
0
func init() {
	potentialQueues := os.Getenv("WORKER_QUEUES")
	potentialConcurrency := os.Getenv("WORKER_CONCURRENCY")

	concurrency = 25

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

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

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

	flag.StringVar(&uri, "uri", redisEnvUri, "the URI of the Redis server")
	flag.StringVar(&namespace, "namespace", "resque:", "the Redis namespace")
	flag.BoolVar(&exitOnComplete, "exit-on-complete", false, "exit when the queue is empty")
	flag.BoolVar(&useNumber, "use-number", false, "use json.Number instead of float64 when decoding numbers in JSON. will default to true soon")
}
Пример #18
0
func init() {
	flag.StringVar(&etcdServer, "etcd.server", "", "Etcd server")
	flag.StringVar(&graphBackend, "graph.backend", "memory", "Specify the graph backend used")
	flag.StringVar(&storageBackend, "storage.backend", "", "Specify the storage backend used")
	flag.StringVar(&useFlowsConnectionType, "use.FlowsConnectionType", "UDP", "Specify the flows connection type between Agent(s) and Analyzer")
	flag.Parse()
}
Пример #19
0
func main() {
	var iaddr string
	flag.StringVar(&iaddr, "iaddr", "tcp://localhost:5555", "input data port")

	var oaddr string
	flag.StringVar(&oaddr, "oaddr", "tcp://localhost:5556", "output data port")

	flag.Parse()

	isck, err := pull.NewSocket()
	if err != nil {
		log.Fatalf("error creating a nanomsg socket: %v\n", err)
	}
	defer isck.Close()

	isck.AddTransport(ipc.NewTransport())
	isck.AddTransport(tcp.NewTransport())

	osck, err := push.NewSocket()
	if err != nil {
		log.Fatalf("error creating output port: %v\n", err)
	}
	defer osck.Close()

	osck.AddTransport(ipc.NewTransport())
	osck.AddTransport(tcp.NewTransport())

	log.Printf("dialing %s ...\n", iaddr)
	err = isck.Dial(iaddr)
	if err != nil {
		log.Fatalf("error dialing: %v\n", err)
	}
	log.Printf("dialing %s ... [done]\n", iaddr)

	log.Printf("dialing %s ...\n", oaddr)
	err = osck.Dial(oaddr)
	if err != nil {
		log.Fatalf("error dialing: %v\n", err)
	}
	log.Printf("dialing %s ... [done]\n", oaddr)

	for {
		msg, err := isck.Recv()
		if err != nil {
			if err == io.EOF || err == mangos.ErrClosed {
				log.Printf("received EOF: %v\n", err)
				break
			}
			log.Fatalf("error receiving data: %v\n", err)
		}
		log.Printf("recv: %v\n", string(msg))

		omsg := bytes.Repeat(msg, 2)
		err = osck.Send(omsg)
		if err != nil {
			log.Fatalf("error sending data: %v\n", err)
		}
	}

}
Пример #20
0
func main() {
	var port int
	var bindAddress string
	var namePrefix string

	flag.StringVar(&bindAddress, "bind", "127.0.0.1",
		"Interface IP to bind to when listening to HTTP connections")
	flag.IntVar(&port, "port", 8912, "Port to listen to for HTTP connections")
	flag.StringVar(&namePrefix, "name-prefix", "mapreduced",
		"Prefix added to the names of all Docker objects created by this")
	flag.Parse()

	if err := controller.Init(namePrefix); err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
	if err := controller.CleanOldState(); err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	var builder TemplateBuilder
	if err := builder.Init(id, zipReaderAt, zipSize); err != nil {
		return err
	}

}
Пример #21
0
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:T2@R,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)
}
Пример #22
0
func main() {
	hd, err := findHomeDir()
	if err != nil {
		log.Fatalf("Couldn't find home dir: %v", err)
	}
	pd := filepath.Join(hd, ".rad", "sad-packs")

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

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

	setupGlobals()
	loadInstalled()
	registerBuildVersion()
	registerAssets()
	go waitAndOpenUrl("http://" + config.addr)
	serve(config.addr)
}
Пример #23
0
func init() {
	flag.StringVar(&serverAddr, "addr", "tcp://127.0.0.1:4000", "server address.")
	flag.StringVar(&certFile, "ca", "ca.pem", "The ca file.")
	flag.StringVar(&privFile, "key", "ca.key", "The ca key file.")
	flag.BoolVar(&useTLS, "use-tls", false, "use TLS")
	flag.Parse()
}
Пример #24
0
func handleUpdate() error {
	var api string
	flag.StringVar(&api, "api", "", "Binding host:port for http/artifact server. Optional if SM_API env is set.")
	flag.StringVar(&statsd.Config.ProducerProperties, "producer.properties", "", "Producer.properties file name.")
	flag.StringVar(&statsd.Config.Topic, "topic", "", "Topic to produce data to.")
	flag.StringVar(&statsd.Config.Transform, "transform", "", "Transofmation to apply to each metric. none|avro|proto")
	flag.StringVar(&statsd.Config.SchemaRegistryUrl, "schema.registry.url", "", "Avro Schema Registry url for transform=avro")
	flag.Float64Var(&statsd.Config.Cpus, "cpu", 0.1, "CPUs per task")
	flag.Float64Var(&statsd.Config.Mem, "mem", 64, "Mem per task")

	flag.Parse()

	if err := resolveApi(api); err != nil {
		return err
	}

	request := statsd.NewApiRequest(statsd.Config.Api + "/api/update")
	request.AddParam("producer.properties", statsd.Config.ProducerProperties)
	request.AddParam("topic", statsd.Config.Topic)
	request.AddParam("transform", statsd.Config.Transform)
	request.AddParam("schema.registry.url", statsd.Config.SchemaRegistryUrl)
	request.AddParam("cpu", strconv.FormatFloat(statsd.Config.Cpus, 'E', -1, 64))
	request.AddParam("mem", strconv.FormatFloat(statsd.Config.Mem, 'E', -1, 64))
	response := request.Get()

	fmt.Println(response.Message)

	return nil
}
Пример #25
0
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)
}
Пример #26
0
// RegisterFlags registers the flags for the given DBConfigFlag.
// For instance, vttablet will register client, dba and repl.
// Returns all registered flags.
func RegisterFlags(flags DBConfigFlag) DBConfigFlag {
	if flags == EmptyConfig {
		panic("No DB config is provided.")
	}
	registeredFlags := EmptyConfig
	if AppConfig&flags != 0 {
		registerConnFlags(&dbConfigs.App.ConnParams, AppConfigName, DefaultDBConfigs.App.ConnParams)
		registeredFlags |= AppConfig
	}
	if DbaConfig&flags != 0 {
		registerConnFlags(&dbConfigs.Dba, DbaConfigName, DefaultDBConfigs.Dba)
		registeredFlags |= DbaConfig
	}
	if FilteredConfig&flags != 0 {
		registerConnFlags(&dbConfigs.Filtered, FilteredConfigName, DefaultDBConfigs.Filtered)
		registeredFlags |= FilteredConfig
	}
	if ReplConfig&flags != 0 {
		registerConnFlags(&dbConfigs.Repl, ReplConfigName, DefaultDBConfigs.Repl)
		registeredFlags |= ReplConfig
	}
	flag.StringVar(&dbConfigs.App.Keyspace, "db-config-app-keyspace", DefaultDBConfigs.App.Keyspace, "db app connection keyspace")
	flag.StringVar(&dbConfigs.App.Shard, "db-config-app-shard", DefaultDBConfigs.App.Shard, "db app connection shard")
	return registeredFlags
}
Пример #27
0
func init() {
	runtime.GOMAXPROCS(4)
	zellij.Workers = 2
	flag.StringVar(&skeleton, "skeleton", "0246", "the zellij skeleton as a string of headings")
	flag.StringVar(&tileSymmetry, "sym", "d4", "the minimum symmetry")
	flag.StringVar(&dir, "dir", "tiles", "output directory")
}
Пример #28
0
func main() {
	flag.StringVar(&route, "path", "./", "Source of files")
	flag.StringVar(&pattern, "pattern", "*", "Pattern search expression of searching files")
	flag.StringVar(&ofilename, "output", "./output.json", "The JSON output file in which we save the results")

	flag.Parse()
	fmt.Println("Find Duplicated Files: Go Walk Hash Calculation...")
	fmt.Println("    * Pattern:", pattern, "\n", "   * Route:", route, "\n", "   * Output filename: ", ofilename)
	//Create ofilename
	f, err := os.Create(ofilename)
	if err != nil {
		log.Fatal(err)
	}
	f.Close()
	//OpenFile and write '[\n'
	f, err = os.OpenFile(ofilename, os.O_APPEND|os.O_WRONLY, 0600)
	if err != nil {
		log.Fatal(err)
	}
	defer f.Close()
	n, err := io.WriteString(f, "[\n")
	if err != nil {
		log.Fatal(n, err)
	}
	//Run the main procedure
	i = 0
	filepath.Walk(route, VisitFile)
	//Write '\n]'
	n, err = io.WriteString(f, "\n]")
	if err != nil {
		log.Fatal(n, err)
	}
	fmt.Println("Written ", i+1, " entries.")
}
Пример #29
0
func main() {
	var duri, furi, suri string
	var withAuth bool
	flag.StringVar(&duri, "show-dir", "", "smb://path/to/dir style directory")
	flag.StringVar(&furi, "show-file", "", "smb://path/to/file style file")
	flag.BoolVar(&withAuth, "with-auth", false, "ask for auth")
	flag.StringVar(&suri, "stress-test", "", "run threaded stress test")
	flag.Parse()

	client := libsmbclient.New()
	//client.SetDebug(99)

	if withAuth {
		client.SetAuthCallback(askAuth)
	}

	var fn func(*libsmbclient.Client, string)
	var uri string
	if duri != "" {
		fn = openSmbdir
		uri = duri
	} else if furi != "" {
		fn = openSmbfile
		uri = furi
	} else if suri != "" {
		fn = multiThreadStressTest
		uri = suri
	} else {
		flag.Usage()
		return
	}
	fn(client, uri)

}
Пример #30
0
func main() {
	var server, client bool
	flag.StringVar(&remote, "remote", "", "remote server")
	flag.IntVar(&port, "port", 8080, "the listen port")
	flag.BoolVar(&server, "server", false, "tls server mode")
	flag.BoolVar(&client, "client", false, "tls client mode")
	flag.StringVar(&cert, "cert", "", "the certificate file")
	flag.StringVar(&key, "key", "", "the private key")
	iniflags.Parse()

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

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

	if client {
		local_main()
		return
	}

	log.Fatal("please use --server or --client to special a work mode")
}