Ejemplo n.º 1
0
func (e *AbstractExecutor) readTrace(pipe *io.PipeReader) {
	defer e.Debugln("ReadTrace finished")

	traceStopped := false
	traceOutputLimit := helpers.NonZeroOrDefault(e.Config.OutputLimit, common.DefaultOutputLimit)
	traceOutputLimit *= 1024

	reader := bufio.NewReader(pipe)
	for {
		r, s, err := reader.ReadRune()
		if s <= 0 {
			break
		} else if traceStopped {
			// ignore symbols if build log exceeded limit
			continue
		} else if err == nil {
			e.Build.WriteRune(r)
		} else {
			// ignore invalid characters
			continue
		}

		if e.Build.BuildLogLen() > traceOutputLimit {
			output := fmt.Sprintf("\n%sBuild log exceeded limit of %v bytes.%s\n",
				helpers.ANSI_BOLD_RED,
				traceOutputLimit,
				helpers.ANSI_RESET,
			)
			e.Build.WriteString(output)
			traceStopped = true
		}
	}

	pipe.Close()
}
Ejemplo n.º 2
0
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
}
Ejemplo n.º 3
0
func (c *RegisterCommand) Execute(context *cli.Context) {
	c.context = context
	err := c.loadConfig()
	if err != nil {
		log.Fatalln(err)
	}
	c.askRunner()

	if !c.LeaveRunner {
		defer func() {
			if r := recover(); r != nil {
				if c.registered {
					common.DeleteRunner(c.URL, c.Token)
				}

				// pass panic to next defer
				panic(r)
			}
		}()

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

		go func() {
			s := <-signals
			common.DeleteRunner(c.URL, c.Token)
			log.Fatalf("RECEIVED SIGNAL: %v", s)
		}()
	}

	c.askExecutor()

	if limit := helpers.NonZeroOrDefault(c.Limit, 0); c.config.Concurrent < limit {
		log.Warningf("Specified limit (%d) larger then current concurrent limit (%d). Concurrent limit will not be enlarged.", limit, c.config.Concurrent)
	}

	switch c.Executor {
	case "docker":
		c.askDocker()
		c.SSH = nil
		c.Parallels = nil
	case "docker-ssh":
		c.askDocker()
		c.askSSHLogin()
		c.Parallels = nil
	case "ssh":
		c.askSSHServer()
		c.askSSHLogin()
		c.Docker = nil
		c.Parallels = nil
	case "parallels":
		c.askParallels()
		c.askSSHServer()
		c.Docker = nil
	}

	c.addRunner(&c.RunnerConfig)
	c.saveConfig()

	log.Printf("Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!")
}