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

Golang common.RunnerConfig类代码示例

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

本文整理汇总了Golang中gitlab.com/gitlab-org/gitlab-ci-multi-runner/common.RunnerConfig的典型用法代码示例。如果您正苦于以下问题:Golang RunnerConfig类的具体用法?Golang RunnerConfig怎么用?Golang RunnerConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: requestBuild

func (mr *MultiRunner) requestBuild(runner *common.RunnerConfig) *common.Build {
	if runner == nil {
		return nil
	}

	if !mr.isHealthy(runner) {
		return nil
	}

	count := mr.buildsForRunner(runner)
	limit := helpers.NonZeroOrDefault(runner.Limit, math.MaxInt32)
	if count >= limit {
		return nil
	}

	buildData, healthy := common.GetBuild(*runner)
	if healthy {
		mr.makeHealthy(runner)
	} else {
		mr.makeUnhealthy(runner)
	}

	if buildData == nil {
		return nil
	}

	mr.debugln("Received new build for", runner.ShortDescription(), "build", buildData.ID)
	newBuild := &common.Build{
		GetBuildResponse: *buildData,
		Runner:           runner,
		BuildAbort:       mr.abortBuilds,
	}
	return newBuild
}
开发者ID:AdrianoJS,项目名称:gitlab-ci-multi-runner,代码行数:34,代码来源:multi.go


示例2: makeUnhealthy

func (mr *MultiRunner) makeUnhealthy(runner *common.RunnerConfig) {
	health := mr.getHealth(runner)
	health.failures++

	if health.failures >= common.HealthyChecks {
		mr.errorln("Runner", runner.ShortDescription(), "is not healthy and will be disabled!")
	}
}
开发者ID:AdrianoJS,项目名称:gitlab-ci-multi-runner,代码行数:8,代码来源:multi.go


示例3: isHealthy

func (mr *MultiRunner) isHealthy(runner *common.RunnerConfig) bool {
	health := mr.getHealth(runner)
	if health.failures < common.HealthyChecks {
		return true
	}

	if time.Since(health.lastCheck) > common.HealthCheckInterval*time.Second {
		mr.errorln("Runner", runner.ShortDescription(), "is not healthy, but will be checked!")
		health.failures = 0
		health.lastCheck = time.Now()
		return true
	}

	return false
}
开发者ID:AdrianoJS,项目名称:gitlab-ci-multi-runner,代码行数:15,代码来源:multi.go


示例4: getHealth

func (mr *MultiRunner) getHealth(runner *common.RunnerConfig) *RunnerHealth {
	mr.healthyLock.Lock()
	defer mr.healthyLock.Unlock()

	if mr.healthy == nil {
		mr.healthy = map[string]*RunnerHealth{}
	}
	health := mr.healthy[runner.UniqueID()]
	if health == nil {
		health = &RunnerHealth{
			lastCheck: time.Now(),
		}
		mr.healthy[runner.UniqueID()] = health
	}
	return health
}
开发者ID:AdrianoJS,项目名称:gitlab-ci-multi-runner,代码行数:16,代码来源:multi.go


示例5: askDocker

func (s *RegistrationContext) askDocker(runnerConfig *common.RunnerConfig) {
	dockerConfig := &common.DockerConfig{}
	dockerConfig.Image = s.ask("docker-image", "Please enter the Docker image (eg. ruby:2.1):")
	dockerConfig.Privileged = s.Bool("docker-privileged")

	if s.askForDockerService("mysql", dockerConfig) {
		runnerConfig.Environment = append(runnerConfig.Environment, "MYSQL_ALLOW_EMPTY_PASSWORD=1")
	}

	s.askForDockerService("postgres", dockerConfig)
	s.askForDockerService("redis", dockerConfig)
	s.askForDockerService("mongo", dockerConfig)

	dockerConfig.Volumes = append(dockerConfig.Volumes, "/cache")

	runnerConfig.Docker = dockerConfig
}
开发者ID:wb14123,项目名称:gitlab-ci-multi-runner-docker,代码行数:17,代码来源:register.go


示例6: askSSH

func (s *RegistrationContext) askSSH(runnerConfig *common.RunnerConfig, serverless bool) {
	runnerConfig.SSH = &ssh.Config{}
	if !serverless {
		if host := s.ask("ssh-host", "Please enter the SSH server address (eg. my.server.com):"); host != "" {
			runnerConfig.SSH.Host = &host
		}
		if port := s.ask("ssh-port", "Please enter the SSH server port (eg. 22):", true); port != "" {
			runnerConfig.SSH.Port = &port
		}
	}
	if user := s.ask("ssh-user", "Please enter the SSH user (eg. root):"); user != "" {
		runnerConfig.SSH.User = &user
	}
	if password := s.ask("ssh-password", "Please enter the SSH password (eg. docker.io):"); password != "" {
		runnerConfig.SSH.Password = &password
	}
}
开发者ID:AdrianoJS,项目名称:gitlab-ci-multi-runner,代码行数:17,代码来源:register.go


示例7: askSSH

func (s *RegistrationContext) askSSH(runnerConfig *common.RunnerConfig, serverless bool) {
	runnerConfig.SSH = &ssh.Config{}
	if !serverless {
		if host := s.ask("ssh-host", "Please enter the SSH server address (eg. my.server.com):"); host != "" {
			runnerConfig.SSH.Host = &host
		}
		if port := s.ask("ssh-port", "Please enter the SSH server port (eg. 22):", true); port != "" {
			runnerConfig.SSH.Port = &port
		}
	}
	if user := s.ask("ssh-user", "Please enter the SSH user (eg. root):"); user != "" {
		runnerConfig.SSH.User = &user
	}
	if password := s.ask("ssh-password", "Please enter the SSH password (eg. docker.io):", true); password != "" {
		runnerConfig.SSH.Password = &password
	}
	if identityFile := s.ask("ssh-identity-file", "Please enter path to SSH identity file (eg. /home/user/.ssh/id_rsa):", true); identityFile != "" {
		runnerConfig.SSH.IdentityFile = &identityFile
	}
}
开发者ID:wb14123,项目名称:gitlab-ci-multi-runner-docker,代码行数:20,代码来源:register.go


示例8: askParallels

func (s *RegistrationContext) askParallels(runnerConfig *common.RunnerConfig) {
	parallelsConfig := &common.ParallelsConfig{}
	parallelsConfig.BaseName = s.ask("parallels-vm", "Please enter the Parallels VM (eg. my-vm):")
	runnerConfig.Parallels = parallelsConfig
}
开发者ID:wb14123,项目名称:gitlab-ci-multi-runner-docker,代码行数:5,代码来源:register.go


示例9: runSingle

func runSingle(c *cli.Context) {
	buildsDir := c.String("builds-dir")
	shell := c.String("shell")
	config := common.NewConfig()
	runner := common.RunnerConfig{
		URL:       c.String("url"),
		Token:     c.String("token"),
		Executor:  c.String("executor"),
		BuildsDir: &buildsDir,
		Shell:     &shell,
	}

	if len(runner.URL) == 0 {
		log.Fatalln("Missing URL")
	}
	if len(runner.Token) == 0 {
		log.Fatalln("Missing Token")
	}
	if len(runner.Executor) == 0 {
		log.Fatalln("Missing Executor")
	}

	go runServer(c.String("addr"))
	go runHerokuURL(c.String("heroku-url"))

	signals := make(chan os.Signal)
	signal.Notify(signals, os.Interrupt, syscall.SIGTERM)

	log.Println("Starting runner for", runner.URL, "with token", runner.ShortDescription(), "...")

	finished := false
	abortSignal := make(chan os.Signal)
	doneSignal := make(chan int, 1)

	go func() {
		interrupt := <-signals
		log.Warningln("Requested exit:", interrupt)
		finished = true

		go func() {
			for {
				abortSignal <- interrupt
			}
		}()

		select {
		case newSignal := <-signals:
			log.Fatalln("forced exit:", newSignal)
		case <-time.After(common.ShutdownTimeout * time.Second):
			log.Fatalln("shutdown timedout")
		case <-doneSignal:
		}
	}()

	for !finished {
		buildData, healthy := common.GetBuild(runner)
		if !healthy {
			log.Println("Runner is not healthy!")
			select {
			case <-time.After(common.NotHealthyCheckInterval * time.Second):
			case <-abortSignal:
			}
			continue
		}

		if buildData == nil {
			select {
			case <-time.After(common.CheckInterval * time.Second):
			case <-abortSignal:
			}
			continue
		}

		newBuild := common.Build{
			GetBuildResponse: *buildData,
			Runner:           &runner,
			BuildAbort:       abortSignal,
		}
		newBuild.AssignID()
		newBuild.Run(config)
	}

	doneSignal <- 0
}
开发者ID:wb14123,项目名称:gitlab-ci-multi-runner-docker,代码行数:84,代码来源:single.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang helpers.BoolOrDefault函数代码示例发布时间:2022-05-28
下一篇:
Golang common.Build类代码示例发布时间: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