Exemplo n.º 1
0
Arquivo: Run.go Projeto: JustAdam/metl
func (v *Run) Run(c cli.Command) {

	jobName := c.Param("jobname").String()
	log.WithFields(
		log.Fields{
			"pkg":  "command",
			"func": "Run",
			"job":  jobName,
		},
	).Info("Starting job")

	j := job.New(metl.GetJobFilePath(jobName))

	j.Lock()

	jf, err := j.Fetch()
	if err != nil {
		log.Fatal("Error fetching job:", err)
	}

	jf.Run()

	j.Unlock()
	j.Done(jf)

	// log stats, notify of errors etc
	// notify of any errors

	// log stats to dashboard, number of processed, rejected rows etc.

	// if parsing option is empty then, we just download the file
}
Exemplo n.º 2
0
Arquivo: main.go Projeto: spekode/odin
func greetGreetee(c cli.Command) {
	greeting := c.Parent().Param("greeting")
	greetee := c.Param("greetee")
	str := fmt.Sprintf("%s %s", greeting, greetee)
	str = styleByFlags(str, c)
	c.Println(str, strings.Join(c.Args().Strings(), " "))
}
Exemplo n.º 3
0
func nodeRun(c cli.Command) {
	switch c.Param("action").String() {
	case "list":
		nodeList(c)
	default:
		cli.ShowUsage(c)
	}
}
Exemplo n.º 4
0
Arquivo: Add.go Projeto: JustAdam/metl
func (v *Add) Run(c cli.Command) {
	jobName := c.Param("jobname").String()
	var job job.Job
	if _, err := toml.DecodeFile(metl.GetJobFilePath(jobName)+".toml", &job); err != nil {
		log.Fatal(err)
	}

	cronfile := filepath.Join(metl.Etl.GetLocalStoragePath(), crontabFile)

	file, err := os.Open(cronfile)
	if err != nil {
		file, err = os.Create(cronfile)
		if err != nil {
			log.WithFields(
				log.Fields{
					"filename": cronfile,
				},
			).Fatal("Unable to create cronfile: ", err)
		}
	}
	defer file.Close()

	err = syscall.Flock(int(file.Fd()), syscall.LOCK_EX)
	if err != nil {
		log.Fatal("Failed to lock file")
	}

	defer func() {
		err = syscall.Flock(int(file.Fd()), syscall.LOCK_UN)
		if err != nil {
			log.Fatal("Failed to unlock file")
		}
	}()

	buffer := make([]string, 0)
	if err = jobIsInFile(file, jobName, &buffer); err != nil {
		log.Fatal(err)
	}
	buffer = append(buffer, fmt.Sprintf("%s %s >> %s%s.log", cmd, jobName, logDir, jobName))

	tmpf, err := ioutil.TempFile(metl.Etl.GetLocalStoragePath(), "tmp")
	if err != nil {
		log.Fatal("Unable to create temporary file.")
	}

	for _, line := range buffer {
		if _, err := tmpf.WriteString(line + "\n"); err != nil {
			log.Fatal("Unable to write to temporary file")
		}
	}

	if err := os.Rename(tmpf.Name(), cronfile); err != nil {
		log.Fatal("Failed to rename temporary lock file:", err)
	}

	// execute /usr/bin/env crontab cronfile
}
Exemplo n.º 5
0
func roleRun(c cli.Command) {
	switch c.Param("action").String() {
	case "list":
		roleList(c)
	case "set":
		roleSet(c)
	default:
		cli.ShowUsage(c)
	}
}
Exemplo n.º 6
0
func serviceRun(c cli.Command) {
	switch c.Param("action").String() {
	case "list":
		serviceList(c)
	case "local":
		serviceLocal(c)
	case "find":
		serviceFind(c)
	default:
		cli.ShowUsage(c)
	}
}
Exemplo n.º 7
0
func cmRun(c cli.Command) {
	switch c.Param("action").String() {
	case "local":
		cmLocal(c)
	case "roll":
		cmRoll(c)
	case "single":
		cmSingle(c)
	default:
		cli.ShowUsage(c)
	}
}
Exemplo n.º 8
0
func roleRun(c cli.Command) {
	switch c.Param("action").String() {
	case "list":
		roleList(c)
	case "set":
		roleSet(c)
	case "listAll":
		roleListAll(c)
	case "find":
		roleFind(c)
	case "append":
		roleAppend(c)
	case "rm":
		roleRm(c)
	default:
		cli.ShowUsage(c)
	}
}
Exemplo n.º 9
0
Arquivo: main.go Projeto: spekode/odin
// the greet command run by the root command
func greet(c cli.Command) {
	greeting := c.Param("greeting")
	str := fmt.Sprintf("%s", greeting)
	str = styleByFlags(str, c)
	c.Println(str)
}