Exemplo n.º 1
0
// prepare exec.Cmd to run mumax3 compute process
func NewProcess(ID string, gpu int, webAddr string) *Process {
	// prepare command
	inputURL := "http://" + ID
	command := *flag_mumax
	gpuFlag := fmt.Sprint(`-gpu=`, gpu)
	httpFlag := fmt.Sprint(`-http=`, webAddr)
	cacheFlag := fmt.Sprint(`-cache=`, *flag_cachedir)
	forceFlag := `-f=0`
	cmd := exec.Command(command, gpuFlag, httpFlag, cacheFlag, forceFlag, inputURL)

	// Pipe stdout, stderr to log file over httpfs
	outDir := util.NoExt(inputURL) + ".out"
	errMkdir := httpfs.Mkdir(outDir)
	if errMkdir != nil {
		SetJobError(ID, errMkdir)
		log.Println("makeProcess", errMkdir)
		j := JobByName(ID)
		if j != nil {
			j.Reque()
		}
		return nil
	}

	out, errD := httpfs.Create(outDir + "/stdout.txt")
	if errD != nil {
		SetJobError(ID, errD)
		log.Println("makeProcess", errD)
		j := JobByName(ID)
		if j != nil {
			j.Reque()
		}
		return nil
	}
	cmd.Stderr = out
	cmd.Stdout = out

	return &Process{ID: ID, Cmd: cmd, Start: time.Now(), Out: out, OutputURL: OutputDir(inputURL), GUI: webAddr}
}
Exemplo n.º 2
0
Arquivo: od.go Projeto: callistoaz/3
// SetOD sets the output directory where auto-saved files will be stored.
// The -o flag can also be used for this purpose.
func InitIO(inputfile, od string, force bool) {
	if outputdir != "" {
		panic("output directory already set")
	}

	InputFile = inputfile
	if !strings.HasSuffix(od, "/") {
		od += "/"
	}
	outputdir = od
	if strings.HasPrefix(outputdir, "http://") {
		httpfs.SetWD(outputdir + "/../")
	}
	LogOut("output directory:", outputdir)

	if force {
		httpfs.Remove(od)
	}

	_ = httpfs.Mkdir(od)

	initLog()
}