• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang config.GetList函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/tsuru/config.GetList函数的典型用法代码示例。如果您正苦于以下问题:Golang GetList函数的具体用法?Golang GetList怎么用?Golang GetList使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了GetList函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: AddBackend

func (r elbRouter) AddBackend(name string) error {
	var err error
	options := elb.CreateLoadBalancer{
		Name: name,
		Listeners: []elb.Listener{
			{
				InstancePort:     80,
				InstanceProtocol: "HTTP",
				LoadBalancerPort: 80,
				Protocol:         "HTTP",
			},
		},
	}
	vpc, _ := config.GetBool("juju:elb-use-vpc")
	if vpc {
		options.Subnets, err = config.GetList("juju:elb-vpc-subnets")
		if err != nil {
			return err
		}
		options.SecurityGroups, err = config.GetList("juju:elb-vpc-secgroups")
		if err != nil {
			return err
		}
		options.Scheme = "internal"
	} else {
		options.AvailZones, err = config.GetList("juju:elb-avail-zones")
		if err != nil {
			return err
		}
	}
	_, err = r.elb().CreateLoadBalancer(&options)
	return router.Store(name, name)
}
开发者ID:rochacon,项目名称:tsuru,代码行数:33,代码来源:router.go


示例2: FlagResolve

func FlagResolve(localAddr *string, serverAddr *string, username *string, password *string) {
	flag.Parse()

	if *helpFlag != false {
		//log.Log("info", "", nil)
		fmt.Println("Usage:...........!!!!!")
		os.Exit(0)
	}
	if *versionFlag != false {
		err := config.ReadConfigFile("../client/config/version.yml")
		if err != nil {
			fmt.Println(err)
			os.Exit(0)
		}
		version, _ := config.GetString("version")
		update, _ := config.GetList("update")
		instruction, _ := config.GetString("instruction")
		fmt.Printf("CaeserClient version: %s\n", version)
		fmt.Printf("New speciality contrast to old version: \n")
		for k, v := range update {
			fmt.Printf("%d-- %s\n", k+1, v)
		}
		fmt.Printf("       %s\n", instruction)
		os.Exit(0)
	}
	if *localFlag != "" {
		*localAddr = *localFlag
		log.Log("info", "you set a new addres", log.Fields{"address": *localFlag})
		//fmt.Println("--Notice: you have set a new address", *localAddr)
	} else {
		//fmt.Println("--Didn't set the start port. Caesar will start at default port.")
		log.Log("info", "Didn't set the start port. Caesar will start at default port.", log.Fields{"default address": *localAddr})
	}
	if *serverFlag != "" {
		fp, err := regexp.MatchString(ipPattern, *serverFlag)
		handleError(err)
		if !fp {
			//fmt.Printf("\"%s\" is not a valid address, please check it and try again!\n", *serverFlag)
			warnMsg := *serverFlag + "is not a valid address, please check it and try again!"
			log.Log("warn", warnMsg, nil)
			os.Exit(0)
		}
		*serverAddr = *serverFlag
		log.Log("info", "You have set a new server address", log.Fields{"new address": *serverAddr})
		//fmt.Println("--Notice: you have set a new server address", *serverAddr)
	} else {
		log.Log("info", "Didn't set the server address.Caesar will connect the default address.", log.Fields{"new address": *serverAddr})
		//fmt.Println("--Didn't set the server address. Caesar will connect the default address.")
	}
	if *userFlag != "" && *passwordFlag != "" {
		*username = *userFlag
		*password = *passwordFlag
		fmt.Println(*username, *password)
	} else {
		//fmt.Println("--Anonymous login, can do nothing! Please login with exgist user or register a new user.")
		log.Log("info", "Anonymous login, can do nothing! Please login with exgist user or register a new user.", nil)
	}
}
开发者ID:jmptrader,项目名称:Caesar,代码行数:58,代码来源:cflag.go


示例3: getDockerServers

func getDockerServers() []cluster.Node {
	servers, _ := config.GetList("docker:servers")
	nodes := []cluster.Node{}
	for _, server := range servers {
		node := cluster.Node{
			Address: server,
		}
		nodes = append(nodes, node)
	}
	return nodes
}
开发者ID:tomzhang,项目名称:golang-devops-stuff,代码行数:11,代码来源:docker.go


示例4: LoadOptions

// LoadOptions TODO: doc
func LoadOptions(configFile string) (Options, error) {
	var options Options
	err := config.ReadConfigFile(configFile)
	if err != nil {
		return options, err
	}

	brokers, err := config.GetList("kafka:brokers")
	if err != nil || len(brokers) == 0 {
		return options, errors.New("You must provide at least one kafka broker")
	}

	zookeepers, err := config.GetList("kafka:zookeeper")
	if err != nil || len(zookeepers) == 0 {
		return options, errors.New("You must provide at least one zookeeper")
	}

	consumerGroup, err := config.GetString("kafka:group")
	if err != nil {
		return options, errors.New("You must provide the consumer group")
	}

	kafkaTopics, err := config.GetList("kafka:topics")
	if err != nil || len(kafkaTopics) == 0 {
		return options, errors.New("You must provide at least one topic")
	}

	consumersCmd, err := config.GetList("consumers")
	if err != nil || len(consumersCmd) == 0 {
		return options, errors.New("You must provide at least one consumer command")
	}

	options = Options{
		Brokers:       brokers,
		Zookeepers:    zookeepers,
		ConsumerGroup: consumerGroup,
		KafkaTopics:   kafkaTopics,
		ConsumersCmd:  consumersCmd,
	}
	return options, nil
}
开发者ID:tulios,项目名称:kafka-revolver,代码行数:42,代码来源:options.go


示例5: start

func (c *container) start(p *dockerProvisioner, app provision.App, isDeploy bool) error {
	port, err := getPort()
	if err != nil {
		return err
	}
	sharedBasedir, _ := config.GetString("docker:sharedfs:hostdir")
	sharedMount, _ := config.GetString("docker:sharedfs:mountpoint")
	sharedIsolation, _ := config.GetBool("docker:sharedfs:app-isolation")
	sharedSalt, _ := config.GetString("docker:sharedfs:salt")
	hostConfig := docker.HostConfig{
		Memory:     app.GetMemory(),
		MemorySwap: app.GetMemory() + app.GetSwap(),
		CPUShares:  int64(app.GetCpuShare()),
	}
	if !isDeploy {
		hostConfig.RestartPolicy = docker.AlwaysRestart()
		hostConfig.PortBindings = map[docker.Port][]docker.PortBinding{
			docker.Port(port + "/tcp"): {{HostIP: "", HostPort: ""}},
		}
		hostConfig.LogConfig = docker.LogConfig{
			Type: "syslog",
			Config: map[string]string{
				"syslog-address": fmt.Sprintf("udp://localhost:%d", getBsSysLogPort()),
			},
		}
	}
	hostConfig.SecurityOpt, _ = config.GetList("docker:security-opts")
	if sharedBasedir != "" && sharedMount != "" {
		if sharedIsolation {
			var appHostDir string
			if sharedSalt != "" {
				h := crypto.SHA1.New()
				io.WriteString(h, sharedSalt+c.AppName)
				appHostDir = fmt.Sprintf("%x", h.Sum(nil))
			} else {
				appHostDir = c.AppName
			}
			hostConfig.Binds = append(hostConfig.Binds, fmt.Sprintf("%s/%s:%s:rw", sharedBasedir, appHostDir, sharedMount))
		} else {
			hostConfig.Binds = append(hostConfig.Binds, fmt.Sprintf("%s:%s:rw", sharedBasedir, sharedMount))
		}
	}
	err = p.getCluster().StartContainer(c.ID, &hostConfig)
	if err != nil {
		return err
	}
	initialStatus := provision.StatusStarting.String()
	if isDeploy {
		initialStatus = provision.StatusBuilding.String()
	}
	return c.setStatus(p, initialStatus, false)
}
开发者ID:keymon,项目名称:tsuru,代码行数:52,代码来源:docker.go


示例6: Create

func (c *Container) Create(args *CreateArgs) error {
	port, err := getPort()
	if err != nil {
		log.Errorf("error on getting port for container %s - %s", c.AppName, port)
		return err
	}
	securityOpts, _ := config.GetList("docker:security-opts")
	var exposedPorts map[docker.Port]struct{}
	if !args.Deploy {
		exposedPorts = map[docker.Port]struct{}{
			docker.Port(port + "/tcp"): {},
		}
	}
	var user string
	if args.Building {
		user = c.user()
	}
	config := docker.Config{
		Image:        args.ImageID,
		Cmd:          args.Commands,
		Entrypoint:   []string{},
		ExposedPorts: exposedPorts,
		AttachStdin:  false,
		AttachStdout: false,
		AttachStderr: false,
		Memory:       args.App.GetMemory(),
		MemorySwap:   args.App.GetMemory() + args.App.GetSwap(),
		CPUShares:    int64(args.App.GetCpuShare()),
		SecurityOpts: securityOpts,
		User:         user,
	}
	c.addEnvsToConfig(args, port, &config)
	opts := docker.CreateContainerOptions{Name: c.Name, Config: &config}
	var nodeList []string
	if len(args.DestinationHosts) > 0 {
		var nodeName string
		nodeName, err = c.hostToNodeAddress(args.Provisioner, args.DestinationHosts[0])
		if err != nil {
			return err
		}
		nodeList = []string{nodeName}
	}
	schedulerOpts := []string{args.App.GetName(), args.ProcessName}
	addr, cont, err := args.Provisioner.Cluster().CreateContainerSchedulerOpts(opts, schedulerOpts, nodeList...)
	if err != nil {
		log.Errorf("error on creating container in docker %s - %s", c.AppName, err)
		return err
	}
	c.ID = cont.ID
	c.HostAddr = net.URLToHost(addr)
	return nil
}
开发者ID:ggarnier,项目名称:tsuru,代码行数:52,代码来源:container.go


示例7: create

// creates a new container in Docker.
func (c *container) create(args runContainerActionsArgs) error {
	port, err := getPort()
	if err != nil {
		log.Errorf("error on getting port for container %s - %s", c.AppName, port)
		return err
	}
	user, err := config.GetString("docker:user")
	if err != nil {
		user, _ = config.GetString("docker:ssh:user")
	}
	securityOpts, _ := config.GetList("docker:security-opts")
	var exposedPorts map[docker.Port]struct{}
	if !args.isDeploy {
		exposedPorts = map[docker.Port]struct{}{
			docker.Port(port + "/tcp"): {},
		}
	}
	config := docker.Config{
		Image:        args.imageID,
		Cmd:          args.commands,
		User:         user,
		ExposedPorts: exposedPorts,
		AttachStdin:  false,
		AttachStdout: false,
		AttachStderr: false,
		Memory:       args.app.GetMemory(),
		MemorySwap:   args.app.GetMemory() + args.app.GetSwap(),
		CPUShares:    int64(args.app.GetCpuShare()),
		SecurityOpts: securityOpts,
	}
	c.addEnvsToConfig(args.app, &config)
	opts := docker.CreateContainerOptions{Name: c.Name, Config: &config}
	var nodeList []string
	if len(args.destinationHosts) > 0 {
		nodeName, err := args.provisioner.hostToNodeAddress(args.destinationHosts[0])
		if err != nil {
			return err
		}
		nodeList = []string{nodeName}
	}
	schedulerOpts := []string{args.app.GetName(), args.processName}
	addr, cont, err := args.provisioner.getCluster().CreateContainerSchedulerOpts(opts, schedulerOpts, nodeList...)
	if err != nil {
		log.Errorf("error on creating container in docker %s - %s", c.AppName, err)
		return err
	}
	c.ID = cont.ID
	c.HostAddr = urlToHost(addr)
	c.User = user
	return nil
}
开发者ID:keymon,项目名称:tsuru,代码行数:52,代码来源:docker.go


示例8: getDockerServers

func getDockerServers() []cluster.Node {
	servers, _ := config.GetList("docker:servers")
	nodes := []cluster.Node{}
	clusterNodes = make(map[string]string)
	for index, server := range servers {
		id := fmt.Sprintf("server%d", index)
		node := cluster.Node{
			ID:      id,
			Address: server,
		}
		nodes = append(nodes, node)
		clusterNodes[id] = server
	}
	return nodes
}
开发者ID:kennylixi,项目名称:tsuru,代码行数:15,代码来源:docker.go


示例9: hostConfig

func (c *Container) hostConfig(app provision.App, isDeploy bool) (*docker.HostConfig, error) {
	sharedBasedir, _ := config.GetString("docker:sharedfs:hostdir")
	sharedMount, _ := config.GetString("docker:sharedfs:mountpoint")
	sharedIsolation, _ := config.GetBool("docker:sharedfs:app-isolation")
	sharedSalt, _ := config.GetString("docker:sharedfs:salt")
	hostConfig := docker.HostConfig{
		CPUShares: int64(app.GetCpuShare()),
	}

	if !isDeploy {
		hostConfig.Memory = app.GetMemory()
		hostConfig.MemorySwap = app.GetMemory() + app.GetSwap()
		hostConfig.RestartPolicy = docker.AlwaysRestart()
		hostConfig.PortBindings = map[docker.Port][]docker.PortBinding{
			docker.Port(c.ExposedPort): {{HostIP: "", HostPort: ""}},
		}
		pool := app.GetPool()
		driver, opts, logErr := LogOpts(pool)
		if logErr != nil {
			return nil, logErr
		}
		hostConfig.LogConfig = docker.LogConfig{
			Type:   driver,
			Config: opts,
		}
	} else {
		hostConfig.OomScoreAdj = 1000
	}

	hostConfig.SecurityOpt, _ = config.GetList("docker:security-opts")
	if sharedBasedir != "" && sharedMount != "" {
		if sharedIsolation {
			var appHostDir string
			if sharedSalt != "" {
				h := crypto.SHA1.New()
				io.WriteString(h, sharedSalt+c.AppName)
				appHostDir = fmt.Sprintf("%x", h.Sum(nil))
			} else {
				appHostDir = c.AppName
			}
			hostConfig.Binds = append(hostConfig.Binds, fmt.Sprintf("%s/%s:%s:rw", sharedBasedir, appHostDir, sharedMount))
		} else {
			hostConfig.Binds = append(hostConfig.Binds, fmt.Sprintf("%s:%s:rw", sharedBasedir, sharedMount))
		}
	}
	return &hostConfig, nil
}
开发者ID:tsuru,项目名称:tsuru,代码行数:47,代码来源:container.go


示例10: startMultipleServersCluster

func (s *S) startMultipleServersCluster() (*cluster.Cluster, []string, error) {
	otherServer, err := dtesting.NewServer("127.0.0.1:0", nil)
	if err != nil {
		return nil, nil, err
	}
	cmutex.Lock()
	defer cmutex.Unlock()
	oldCluster := dCluster
	oldServers, err := config.GetList("docker:servers")
	if err != nil {
		oldServers = []string{}
	}
	config.Set("docker:servers", []string{"http://serverAddr0:8888", "http://serverAddr1:8888"})
	dCluster, err = cluster.New(nil, &mapStorage{},
		cluster.Node{ID: "server0", Address: s.server.URL()},
		cluster.Node{ID: "server1", Address: otherServer.URL()},
	)
	if err != nil {
		return nil, nil, err
	}
	return oldCluster, oldServers, nil
}
开发者ID:kennylixi,项目名称:tsuru,代码行数:22,代码来源:suite_test.go


示例11: FlagResolve

func FlagResolve(listenAddr *string) {
	flag.Parse()

	if *versionFlag != false {
		err := config.ReadConfigFile("../config/server.yml")
		if err != nil {
			fmt.Println(err)
			os.Exit(0)
		}
		version, _ := config.GetString("version")
		update, _ := config.GetList("update")
		instruction, _ := config.GetString("instruction")
		fmt.Printf("CaeserClient version: %s\n", version)
		fmt.Printf("New speciality contrast to old version: \n")
		for k, v := range update {
			fmt.Printf("%d-- %s\n", k+1, v)
		}
		fmt.Printf("       %s\n", instruction)
		os.Exit(0)
	}
	if *runtimeFlag == "min" {
		log.Log("warn", "Start up with least CPU's resousces", log.Fields{"Occupy CPU Num": 1})
	}

	if *listenFlag != "" {
		fp, err := regexp.MatchString(ipPattern, *listenFlag)
		handleError(err)
		if !fp {
			//fmt.Printf("\"%s\" is not a valid address, please check it and try again!\n", *listenFlag)
			log.Log("fatal", "-address is not a valid address, please check it and try again!", map[string]interface{}{"address": *listenFlag})
			os.Exit(0)
		}
		*listenAddr = *listenFlag
		fmt.Println("--Notice: you have set a new listen address", *listenAddr)
	} else {
		//fmt.Println("--Didn't set the listen address. Server will start at default address.")
		log.Log("info", "Didn't set the listen address. Server will start at default address.", log.Fields{"Default Address": *listenAddr})
	}
}
开发者ID:jmptrader,项目名称:Caesar,代码行数:39,代码来源:flag.go


示例12: Start

func (c *Container) Start(args *StartArgs) error {
	port, err := getPort()
	if err != nil {
		return err
	}
	sharedBasedir, _ := config.GetString("docker:sharedfs:hostdir")
	sharedMount, _ := config.GetString("docker:sharedfs:mountpoint")
	sharedIsolation, _ := config.GetBool("docker:sharedfs:app-isolation")
	sharedSalt, _ := config.GetString("docker:sharedfs:salt")
	hostConfig := docker.HostConfig{
		Memory:     args.App.GetMemory(),
		MemorySwap: args.App.GetMemory() + args.App.GetSwap(),
		CPUShares:  int64(args.App.GetCpuShare()),
	}
	if !args.Deploy {
		hostConfig.RestartPolicy = docker.AlwaysRestart()
		hostConfig.PortBindings = map[docker.Port][]docker.PortBinding{
			docker.Port(port + "/tcp"): {{HostIP: "", HostPort: ""}},
		}
		logConf := DockerLog{}
		pool := args.App.GetPool()
		driver, opts, logErr := logConf.LogOpts(pool)
		if logErr != nil {
			return err
		}
		hostConfig.LogConfig = docker.LogConfig{
			Type:   driver,
			Config: opts,
		}
	}
	hostConfig.SecurityOpt, _ = config.GetList("docker:security-opts")
	if sharedBasedir != "" && sharedMount != "" {
		if sharedIsolation {
			var appHostDir string
			if sharedSalt != "" {
				h := crypto.SHA1.New()
				io.WriteString(h, sharedSalt+c.AppName)
				appHostDir = fmt.Sprintf("%x", h.Sum(nil))
			} else {
				appHostDir = c.AppName
			}
			hostConfig.Binds = append(hostConfig.Binds, fmt.Sprintf("%s/%s:%s:rw", sharedBasedir, appHostDir, sharedMount))
		} else {
			hostConfig.Binds = append(hostConfig.Binds, fmt.Sprintf("%s:%s:rw", sharedBasedir, sharedMount))
		}
	}
	allocator, _ := config.GetString("docker:port-allocator")
	if allocator == "" {
		allocator = "docker"
	}
	switch allocator {
	case "tsuru":
		err = c.startWithPortSearch(args.Provisioner, &hostConfig)
	case "docker":
		err = args.Provisioner.Cluster().StartContainer(c.ID, &hostConfig)
	default:
		return fmt.Errorf("invalid docker:port-allocator: %s", allocator)
	}
	if err != nil {
		return err
	}
	initialStatus := provision.StatusStarting
	if args.Deploy {
		initialStatus = provision.StatusBuilding
	}
	return c.SetStatus(args.Provisioner, initialStatus, false)
}
开发者ID:zhenruyan,项目名称:tsuru,代码行数:67,代码来源:container.go


示例13: createBsContainer

func (runBs) createBsContainer(dockerEndpoint string) error {
	client, err := docker.NewClient(dockerEndpoint)
	if err != nil {
		return err
	}
	bsImage, _ := config.GetString("docker:bs:image")
	if bsImage == "" {
		bsImage = "tsuru/bs"
	}
	tsuruEndpoint, _ := config.GetString("host")
	if !strings.HasPrefix(tsuruEndpoint, "http://") && !strings.HasPrefix(tsuruEndpoint, "https://") {
		tsuruEndpoint = "http://" + tsuruEndpoint
	}
	interval, _ := config.GetInt("docker:bs:reporter-interval")
	tsuruEndpoint = strings.TrimRight(tsuruEndpoint, "/") + "/"
	token, err := app.AuthScheme.AppLogin(app.InternalAppName)
	if err != nil {
		return err
	}
	hostConfig := docker.HostConfig{RestartPolicy: docker.AlwaysRestart()}
	endpoint := dockerEndpoint
	socket, _ := config.GetString("docker:bs:socket")
	if socket != "" {
		hostConfig.Binds = []string{fmt.Sprintf("%s:/var/run/docker.sock:rw", socket)}
		endpoint = "unix:///var/run/docker.sock"
	}
	sysLogExternalPort := getBsSysLogPort()
	hostConfig.PortBindings = map[docker.Port][]docker.PortBinding{
		docker.Port("514/udp"): {
			docker.PortBinding{
				HostIP:   "0.0.0.0",
				HostPort: strconv.Itoa(sysLogExternalPort),
			},
		},
	}
	env := []string{
		"DOCKER_ENDPOINT=" + endpoint,
		"TSURU_ENDPOINT=" + tsuruEndpoint,
		"TSURU_TOKEN=" + token.GetValue(),
		"STATUS_INTERVAL=" + strconv.Itoa(interval),
		"SYSLOG_LISTEN_ADDRESS=udp://0.0.0.0:514",
	}
	addresses, _ := config.GetList("docker:bs:syslog-forward-addresses")
	if len(addresses) > 0 {
		env = append(env, "SYSLOG_FORWARD_ADDRESSES="+strings.Join(addresses, ","))
	}
	opts := docker.CreateContainerOptions{
		Name:       "big-sibling",
		HostConfig: &hostConfig,
		Config: &docker.Config{
			Image: bsImage,
			Env:   env,
			ExposedPorts: map[docker.Port]struct{}{
				docker.Port(strconv.Itoa(sysLogExternalPort) + "/udp"): {},
			},
		},
	}
	container, err := client.CreateContainer(opts)
	if err == docker.ErrContainerAlreadyExists {
		err = client.RemoveContainer(docker.RemoveContainerOptions{ID: opts.Name, Force: true})
		if err != nil {
			return err
		}
		container, err = client.CreateContainer(opts)
	}
	if err == docker.ErrNoSuchImage {
		pullOpts := docker.PullImageOptions{Repository: bsImage}
		err = client.PullImage(pullOpts, getRegistryAuthConfig())
		if err != nil {
			return err
		}
		container, err = client.CreateContainer(opts)
	}
	if err == docker.ErrContainerAlreadyExists {
		err = client.RemoveContainer(docker.RemoveContainerOptions{ID: opts.Name, Force: true})
		if err != nil {
			return err
		}
		container, err = client.CreateContainer(opts)
	}
	if err != nil {
		return err
	}
	return client.StartContainer(container.ID, &hostConfig)
}
开发者ID:RichardKnop,项目名称:tsuru,代码行数:85,代码来源:queue_task.go


示例14: Create

func (c *Container) Create(args *CreateArgs) error {
	securityOpts, _ := config.GetList("docker:security-opts")
	var exposedPorts map[docker.Port]struct{}
	if !args.Deploy {
		if c.ExposedPort == "" {
			c.ExposedPort = dockercommon.WebProcessDefaultPort() + "/tcp"
		}
		exposedPorts = map[docker.Port]struct{}{
			docker.Port(c.ExposedPort): {},
		}
	}
	var user string
	if args.Building {
		user = c.user()
	}
	routerName, err := args.App.GetRouter()
	if err != nil {
		return err
	}
	routerType, _, err := router.Type(routerName)
	if err != nil {
		return err
	}
	hostConf, err := c.hostConfig(args.App, args.Deploy)
	if err != nil {
		return err
	}
	conf := docker.Config{
		Image:        args.ImageID,
		Cmd:          args.Commands,
		Entrypoint:   []string{},
		ExposedPorts: exposedPorts,
		AttachStdin:  false,
		AttachStdout: false,
		AttachStderr: false,
		Memory:       hostConf.Memory,
		MemorySwap:   hostConf.MemorySwap,
		CPUShares:    hostConf.CPUShares,
		SecurityOpts: securityOpts,
		User:         user,
		Labels: map[string]string{
			"tsuru.container":    strconv.FormatBool(true),
			"tsuru.app.name":     args.App.GetName(),
			"tsuru.app.platform": args.App.GetPlatform(),
			"tsuru.process.name": c.ProcessName,
			"tsuru.router.name":  routerName,
			"tsuru.router.type":  routerType,
		},
	}
	c.addEnvsToConfig(args, strings.TrimSuffix(c.ExposedPort, "/tcp"), &conf)
	opts := docker.CreateContainerOptions{Name: c.Name, Config: &conf, HostConfig: hostConf}
	var nodeList []string
	if len(args.DestinationHosts) > 0 {
		var node cluster.Node
		node, err = args.Provisioner.GetNodeByHost(args.DestinationHosts[0])
		if err != nil {
			return err
		}
		nodeList = []string{node.Address}
	}
	schedulerOpts := &SchedulerOpts{
		AppName:       args.App.GetName(),
		ProcessName:   args.ProcessName,
		ActionLimiter: args.Provisioner.ActionLimiter(),
	}
	addr, cont, err := args.Provisioner.Cluster().CreateContainerSchedulerOpts(opts, schedulerOpts, net.StreamInactivityTimeout, nodeList...)
	hostAddr := net.URLToHost(addr)
	if schedulerOpts.LimiterDone != nil {
		schedulerOpts.LimiterDone()
	}
	if err != nil {
		log.Errorf("error on creating container in docker %s - %s", c.AppName, err)
		return err
	}
	c.ID = cont.ID
	c.HostAddr = hostAddr
	return nil
}
开发者ID:tsuru,项目名称:tsuru,代码行数:78,代码来源:container.go



注:本文中的github.com/tsuru/config.GetList函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang config.GetString函数代码示例发布时间:2022-05-28
下一篇:
Golang config.GetInt函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap