예제 #1
0
파일: flagenv.go 프로젝트: plimble/flagenv
func (c *FlagEnv) AddStringSlice(name string, val []string, usage string) {
	strslice := cli.StringSlice(val)
	camelName := camelCase(name)
	envName := c.toENVName(name)
	c.flags[camelName] = &flag{
		name: name,
		cliFlag: cli.StringSliceFlag{
			Name:   name,
			Value:  &strslice,
			Usage:  usage,
			EnvVar: c.toENVName(name),
		},
		flagType:    stringSliceFlag,
		envName:     envName,
		defStrSlice: val,
	}
}
예제 #2
0
파일: flags.go 프로젝트: dhiltgen/swarm
	return os.Getenv("SWARM_DISCOVERY")
}

var (
	flJoinAdvertise = cli.StringFlag{
		Name:   "advertise, addr",
		Usage:  "Address of the Docker Engine joining the cluster. Swarm manager(s) MUST be able to reach the Docker Engine at this address.",
		EnvVar: "SWARM_ADVERTISE",
	}
	flManageAdvertise = cli.StringFlag{
		Name:   "advertise, addr",
		Usage:  "Address of the swarm manager joining the cluster. Other swarm manager(s) MUST be able to reach the swarm manager at this address.",
		EnvVar: "SWARM_ADVERTISE",
	}
	// hack for go vet
	flHostsValue = cli.StringSlice([]string{"tcp://127.0.0.1:2375"})

	flHosts = cli.StringSliceFlag{
		Name:   "host, H",
		Value:  &flHostsValue,
		Usage:  "ip/socket to listen on",
		EnvVar: "SWARM_HOST",
	}
	flHeartBeat = cli.StringFlag{
		Name:  "heartbeat",
		Value: "20s",
		Usage: "period between each heartbeat",
	}
	flTTL = cli.StringFlag{
		Name:  "ttl",
		Value: "60s",
예제 #3
0
파일: flags.go 프로젝트: abronan/proton
package main

import "github.com/codegangsta/cli"

var (
	flHostsValue = cli.StringSlice([]string{"127.0.0.1:6744"})

	flHosts = cli.StringSliceFlag{
		Name:   "host, H",
		Value:  &flHostsValue,
		Usage:  "ip/socket to listen on",
		EnvVar: "PROTON_HOST",
	}

	flFirst = cli.BoolFlag{
		Name:   "first",
		Usage:  "be the first node for topology construction; implied by --first=true",
		EnvVar: "PROTON_FIRST",
	}

	flWithRaftLogs = cli.BoolFlag{
		Name:   "withRaftLogs",
		Usage:  "print raft logs for heartbeats and log processing",
		EnvVar: "PROTON_WITH_RAFT_LOGS",
	}

	flReplication = cli.BoolFlag{
		Name:   "replication, R",
		Usage:  "take part in log replication; implied by --replication=true",
		EnvVar: "PROTON_LOG_REPLICATION",
	}
예제 #4
0
var (
	flStore = cli.StringFlag{
		Name:  "rootdir",
		Value: homepath(".swarm"),
		Usage: "",
	}
	flAddr = cli.StringFlag{
		Name:   "addr",
		Value:  "127.0.0.1:2375",
		Usage:  "ip to advertise",
		EnvVar: "SWARM_ADDR",
	}

	// hack for go vet
	flHostsValue = cli.StringSlice([]string{"tcp://127.0.0.1:2375"})

	flHosts = cli.StringSliceFlag{
		Name:   "host, H",
		Value:  &flHostsValue,
		Usage:  "ip/socket to listen on",
		EnvVar: "SWARM_HOST",
	}
	flHeartBeat = cli.IntFlag{
		Name:  "heartbeat, hb",
		Value: 25,
		Usage: "time in second between each heartbeat",
	}
	flEnableCors = cli.BoolFlag{
		Name:  "api-enable-cors, cors",
		Usage: "enable CORS headers in the remote API",
예제 #5
0
파일: cmd.go 프로젝트: carriercomm/serviced
// New instantiates a new command-line client
func New(driver api.API) *ServicedCli {
	var (
		rpcPort          = configInt("RPC_PORT", defaultRPCPort)
		agentEndpoint    = getLocalAgentEndpoint(rpcPort)
		varPath          = api.GetVarPath()
		esStartupTimeout = api.GetESStartupTimeout()
		dockerDNS        = cli.StringSlice(api.GetDockerDNS())
	)

	c := &ServicedCli{
		driver: driver,
		app:    cli.NewApp(),
	}

	c.app.Name = "serviced"
	c.app.Usage = "A container-based management system"
	c.app.Version = fmt.Sprintf("%s - %s ", servicedversion.Version, servicedversion.Gitcommit)
	c.app.EnableBashCompletion = true
	c.app.Before = c.cmdInit
	staticIps := cli.StringSlice{}
	if len(configEnv("STATIC_IPS", "")) > 0 {
		staticIps = cli.StringSlice(strings.Split(configEnv("STATIC_IPS", ""), ","))
	}

	defaultDockerRegistry := docker.DEFAULT_REGISTRY
	if hostname, err := os.Hostname(); err == nil {
		defaultDockerRegistry = fmt.Sprintf("%s:5000", hostname)
	}

	zks := cli.StringSlice{}
	if len(configEnv("ZK", "")) > 0 {
		zks = cli.StringSlice(strings.Split(configEnv("ZK", ""), ","))
	}

	isvcs_env := cli.StringSlice{}
	if env := configEnv("ISVCS_ENV", ""); len(env) != 0 {
		isvcs_env = append(isvcs_env, env)
	}
	for i := 0; ; i++ {
		if env := configEnv(fmt.Sprintf("ISVCS_ENV_%d", i), ""); len(env) != 0 {
			isvcs_env = append(isvcs_env, env)
		} else {
			break
		}
	}

	/* TODO: 1.1
	remotezks := cli.StringSlice{}
	if len(configEnv("REMOTE_ZK", "")) > 0 {
		zks = cli.StringSlice(strings.Split(configEnv("REMOTE_ZK", ""), ","))
	}
	*/

	aliases := cli.StringSlice{}
	if len(configEnv("VHOST_ALIASES", "")) > 0 {
		aliases = cli.StringSlice(strings.Split(configEnv("VHOST_ALIASES", ""), ","))
	}

	defaultAdminGroup := "sudo"
	if utils.Platform == utils.Rhel {
		defaultAdminGroup = "wheel"
	}

	c.app.Flags = []cli.Flag{
		cli.StringFlag{"docker-registry", configEnv("DOCKER_REGISTRY", defaultDockerRegistry), "local docker registry to use"},
		cli.StringSliceFlag{"static-ip", &staticIps, "static ips for this agent to advertise"},
		cli.StringFlag{"endpoint", configEnv("ENDPOINT", agentEndpoint), fmt.Sprintf("endpoint for remote serviced (example.com:%d)", defaultRPCPort)},
		cli.StringFlag{"outbound", configEnv("OUTBOUND_IP", ""), "outbound ip address"},
		cli.StringFlag{"uiport", configEnv("UI_PORT", ":443"), "port for ui"},
		cli.StringFlag{"nfs-client", configEnv("NFS_CLIENT", "1"), "establish agent as an nfs client sharing data, 0 to disable"},
		cli.IntFlag{"listen", rpcPort, fmt.Sprintf("rpc port for serviced (%d)", defaultRPCPort)},
		cli.StringSliceFlag{"docker-dns", &dockerDNS, "docker dns configuration used for running containers"},
		cli.BoolFlag{"master", "run in master mode, i.e., the control center service"},
		cli.BoolFlag{"agent", "run in agent mode, i.e., a host in a resource pool"},
		cli.IntFlag{"mux", configInt("MUX_PORT", 22250), "multiplexing port"},
		cli.StringFlag{"var", configEnv("VARPATH", varPath), "path to store serviced data"},
		cli.StringFlag{"keyfile", configEnv("KEY_FILE", ""), "path to private key file (defaults to compiled in private key)"},
		cli.StringFlag{"certfile", configEnv("CERT_FILE", ""), "path to public certificate file (defaults to compiled in public cert)"},
		cli.StringSliceFlag{"zk", &zks, "Specify a zookeeper instance to connect to (e.g. -zk localhost:2181)"},
		// TODO: 1.1
		// cli.StringSliceFlag{"remote-zk", &remotezks, "Specify a zookeeper instance to connect to (e.g. -remote-zk remote:2181)"},
		cli.StringSliceFlag{"mount", &cli.StringSlice{}, "bind mount: DOCKER_IMAGE,HOST_PATH[,CONTAINER_PATH]"},
		cli.StringFlag{"fstype", configEnv("FS_TYPE", "rsync"), "driver for underlying file system"},
		cli.StringSliceFlag{"alias", &aliases, "list of aliases for this host, e.g., localhost"},
		cli.IntFlag{"es-startup-timeout", esStartupTimeout, "time to wait on elasticsearch startup before bailing"},
		cli.IntFlag{"max-container-age", configInt("MAX_CONTAINER_AGE", 60*60*24), "maximum age (seconds) of a stopped container before removing"},
		cli.IntFlag{"max-dfs-timeout", configInt("MAX_DFS_TIMEOUT", 60*5), "max timeout to perform a dfs snapshot"},
		cli.StringFlag{"virtual-address-subnet", configEnv("VIRTUAL_ADDRESS_SUBNET", "10.3"), "/16 subnet for virtual addresses"},
		cli.StringFlag{"master-pool-id", configEnv("MASTER_POOLID", "default"), "master's pool ID"},
		cli.StringFlag{"admin-group", configEnv("ADMIN_GROUP", defaultAdminGroup), "system group that can log in to control center"},

		cli.BoolTFlag{"report-stats", "report container statistics"},
		cli.StringFlag{"host-stats", configEnv("STATS_PORT", "127.0.0.1:8443"), "container statistics for host:port"},
		cli.IntFlag{"stats-period", configInt("STATS_PERIOD", 10), "Period (seconds) for container statistics reporting"},
		cli.StringFlag{"mc-username", "scott", "Username for Zenoss metric consumer"},
		cli.StringFlag{"mc-password", "tiger", "Password for the Zenoss metric consumer"},
		cli.StringFlag{"cpuprofile", "", "write cpu profile to file"},
		cli.StringSliceFlag{"isvcs-env", &isvcs_env, "internal-service environment variable: ISVC:KEY=VAL"},
		cli.IntFlag{"debug-port", configInt("DEBUG_PORT", 6006), "Port on which to listen for profiler connections"},
		cli.IntFlag{"max-rpc-clients", configInt("MAX_RPC_CLIENTS", 3), "max number of rpc clients to an endpoint"},
		cli.IntFlag{"rpc-dial-timeout", configInt("RPC_DIAL_TIMEOUT", 30), "timeout for creating rpc connections"},
		cli.IntFlag{"snapshot-ttl", configInt("SNAPSHOT_TTL", 12), "snapshot TTL in hours, 0 to disable"},

		// Reimplementing GLOG flags :(
		cli.BoolTFlag{"logtostderr", "log to standard error instead of files"},
		cli.BoolFlag{"alsologtostderr", "log to standard error as well as files"},
		cli.StringFlag{"logstashurl", configEnv("LOG_ADDRESS", "127.0.0.1:5042"), "logstash url and port"},
		cli.StringFlag{"logstash-es", configEnv("LOGSTASH_ES", "127.0.0.1:9100"), "host and port for logstash elastic search"},
		cli.IntFlag{"logstash-max-days", configInt("LOGSTASH_MAX_DAYS", 14), "days to keep Logstash data"},
		cli.IntFlag{"logstash-max-size", configInt("LOGSTASH_MAX_SIZE", 10), "max size of Logstash data to keep in gigabytes"},
		cli.IntFlag{"v", configInt("LOG_LEVEL", 0), "log level for V logs"},
		cli.StringFlag{"stderrthreshold", "", "logs at or above this threshold go to stderr"},
		cli.StringFlag{"vmodule", "", "comma-separated list of pattern=N settings for file-filtered logging"},
		cli.StringFlag{"log_backtrace_at", "", "when logging hits line file:N, emit a stack trace"},
	}

	c.initVersion()
	c.initPool()
	c.initHealthCheck()
	c.initHost()
	c.initTemplate()
	c.initService()
	c.initSnapshot()
	c.initLog()
	c.initBackup()
	c.initMetric()
	c.initDocker()
	c.initScript()

	return c
}
예제 #6
0
파일: main.go 프로젝트: pjvds/edgy
		work.Done()
	}

	work.Add(len(all))
	for _, one := range all {
		go pipe(one)
	}

	go func() {
		work.Wait()
		close(out)
	}()
	return out
}

var defaultHosts = cli.StringSlice([]string{"localhost:5050"})

func main() {
	flag.Parse()
	tidy.Configure().LogFromLevelSpecifiedByEnvironment().To(tidy.Console).MustBuildDefault()

	app := cli.NewApp()
	app.Name = "edgy command line interface"
	app.Commands = []cli.Command{
		cli.Command{
			Name: "publish",
			Flags: []cli.Flag{
				cli.StringFlag{
					Name:   "hosts",
					Value:  "localhost:5050",
					EnvVar: "EDGY_HOSTS",