Skip to content

Commit

Permalink
mumax3-server: pay more attention to pre-existing output dir
Browse files Browse the repository at this point in the history
  • Loading branch information
barnex committed Jan 7, 2015
1 parent 602384d commit c30de2a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
12 changes: 11 additions & 1 deletion cmd/mumax3-server/compute.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,17 @@ func NewProcess(ID string, gpu int, webAddr string) *Process {

// Pipe stdout, stderr to log file over httpfs
outDir := util.NoExt(inputURL) + ".out"
httpfs.Mkdir(outDir)
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)
Expand Down
6 changes: 2 additions & 4 deletions engine/od.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package engine

import (
"github.com/mumax/3/httpfs"
"github.com/mumax/3/util"
"strings"
)

Expand Down Expand Up @@ -40,9 +39,8 @@ func InitIO(inputfile, od string, force bool) {
if force {
httpfs.Remove(od)
}
if err := httpfs.Mkdir(od); err != nil {
util.FatalErr(err)
}

_ = httpfs.Mkdir(od)

initLog()
}
4 changes: 2 additions & 2 deletions httpfs/httpfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
)

var (
Logging = true // enables logging
Logging = false // enables logging
wd = "" // working directory, see SetWD
lock sync.Mutex // synchronous local FS access to avoid races
)
Expand Down Expand Up @@ -316,7 +316,7 @@ func httpRemove(URL string) error {
func localMkdir(fname string) error {
lock.Lock()
defer lock.Unlock()
return os.MkdirAll(fname, DirPerm)
return os.Mkdir(fname, DirPerm)
}

func localTouch(fname string) error {
Expand Down
10 changes: 0 additions & 10 deletions httpfs/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ func MustOpen(URL string) io.ReadCloser {
return f
}

//func Touch(URL string) error {
// return Append(URL, []byte{})
//}

type bufWriter struct {
buf *bufio.Writer
}
Expand All @@ -68,7 +64,6 @@ type appendWriter struct {
byteCount int64
}

// TODO: buffer heavily, Flush() on close
func (w *appendWriter) Write(p []byte) (int, error) {
err := AppendSize(w.URL, p, w.byteCount)
if err != nil {
Expand All @@ -77,8 +72,3 @@ func (w *appendWriter) Write(p []byte) (int, error) {
w.byteCount += int64(len(p))
return len(p), nil
}

// TODO: flush
//func (w *appendWriter) Close() error {
//return nil
//}

0 comments on commit c30de2a

Please sign in to comment.