예제 #1
0
파일: Run.go 프로젝트: 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
}
예제 #2
0
func submitHandler(req *web.Request) {
	w := req.Respond(web.StatusOK,
		web.HeaderContentType, "application/json; charset=utf-8",
		"Access-Control-Allow-Origin", "*")
	encoder := json.NewEncoder(w)
	j := job.New(req.Param.Get("email"), req.Param.Get("url"))
	if err, ok := j.IsValid(); ok {
		j.Progress("Working...")
		extractor.Extract(j)
		encoder.Encode(JSON{
			"message": "Submitted! Hang tight...",
			"id":      j.KeyString(),
		})
	} else {
		encoder.Encode(JSON{
			"message": err,
		})
	}
}