func initVar() {
	brokerAddr = "127.0.0.1"
	brokerPort = "4150"
	nsqLookUpHost = "127.0.0.1"
	nsqLookUpPort = "4161"
	logger = logs.NewLogger("[TOTO-BUILD main] : ", logs.NewConsoleAppender(logs.INFO))
}
Example #2
0
// todo get the log level as an input
func main() {
	logger = logs.NewLogger("[TOTO-BUILD main] : ", logs.NewConsoleAppender(logs.INFO))
	logger.Info("application is starting")
	flag.StringVar(&brokerAddr, "broker-addr", "127.0.0.1", "address of the broker. Should be accessible from scheduler")
	flag.StringVar(&brokerPort, "broker-port", "4150", "port of the broker. Should be accessible from scheduler")
	flag.StringVar(&nsqLookUpHost, "lookup-addrr", "127.0.0.1", "address of the lookup service. Used by toto-build to get topic used for communications")
	flag.StringVar(&nsqLookUpPort, "lookup-port", "4161", "port of the lookup service.")
	flag.Parse()
}
package build

import (
	"bufio"
	"fmt"
	"github.com/vil-coyote-acme/toto-build-common/logs"
	"github.com/vil-coyote-acme/toto-build-common/message"
	"io"
	"os/exec"
	"syscall"
)

// todo limit the number of goroutines !

var (
	logger = logs.NewLogger("[BUILD-ENGINE] : ", logs.NewConsoleAppender(logs.INFO))
)

// will lauch job on incoming toWork
func ExecuteJob(toWorkChan chan message.ToWork, reportChan chan message.Report) {
	// one goroutine for launching jobs. May (must ?) be merge with routine in handler ?
	go func() {
		for toWork := range toWorkChan {
			logger.Infof("receive one job : %s", toWork)
			switch toWork.Cmd {
			case message.PACKAGE:
				BuildPackage(toWork, reportChan)
			case message.TEST:
				TestPackage(toWork, reportChan)
			case message.HELLO:
				reportChan <- message.Report{toWork.JobId, message.SUCCESS, []string{"Hello"}}
Example #4
0
package scm

import (
	"github.com/libgit2/git2go"
	"github.com/vil-coyote-acme/toto-build-common/logs"
	"github.com/vil-coyote-acme/toto-build-common/message"
	"os"
)

var (
	logger *logs.Logger = logs.NewLogger("[GIT-FETCHER] : ", logs.NewConsoleAppender(logs.INFO))
)

func Fetch(mes message.ToWork) (err error) {
	goPath := os.Getenv("GOPATH")
	_, errGoPath := os.Open(goPath + "/src")
	if errGoPath != nil {
		logger.Errorf("error while checking %s", goPath+"/src")
		err = errGoPath
		return
	}
	_, errClone := git.Clone(mes.RepoUrl, goPath+"/src", new(git.CloneOptions))
	if errClone != nil {
		logger.Errorf("error while trying to checkout %s on ", mes.RepoUrl, goPath+"/src")
		return errClone
	}
	logger.Infof("successfully clone %s into %s", mes.RepoUrl, goPath+"/src")
	return
}