Skip to content

Commit

Permalink
tool operation cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
James Nesbitt committed Oct 30, 2015
1 parent cce1801 commit 698230f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
4 changes: 4 additions & 0 deletions operation_help.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ OPERATIONS:
unpause
remove
scale
tool
The first topic passed in is assumed to be a help operation.
`)
}
Expand Down
15 changes: 7 additions & 8 deletions tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (tools Tools) GetToolsFromYaml(conf *Conf, log Log, source []byte, overwrit
}

tool.conf = conf
tool.log = log
tool.log = log.ChildLog("SCRIPT")

if exists:=tools[name]; exists==nil || overwrite {
tools[name] = Tool(&tool)
Expand Down Expand Up @@ -59,15 +59,14 @@ type Tool_Script struct {
}
func (tool *Tool_Script) Run(flags []string) bool {

tool.log.DebugObject( LOG_SEVERITY_MESSAGE, "TOOL SCRIPT", tool.Script)

// tool.Script = []string{"ps", "-aux"}

cmd_first := tool.Script[0]
args := []string{}
if len(tool.Script)>1 {
args = tool.Script[1:]
}
if len(flags)>0 {
args = append(args, flags...)
}

if path.IsAbs(cmd_first) {

Expand All @@ -90,15 +89,15 @@ tool.log.DebugObject( LOG_SEVERITY_MESSAGE, "TOOL SCRIPT", tool.Script)
cmd.Env = append(cmd.Env, tool.Env...)
}

tool.log.Message("Running Script")
tool.log.Message("RUN: "+cmd_first)
err := cmd.Start()

if err!=nil {
tool.log.Error("SCRIPT FAILED => "+err.Error())
tool.log.Error("FAILED => "+err.Error())
return false
}

tool.log.Message("SCRIPT RUN")
err = cmd.Wait()
tool.log.Message("FINISHED")
return err==nil
}

0 comments on commit 698230f

Please sign in to comment.