Redesign and taking xapp-framework into use
[ric-plt/vespamgr.git] / cmd / vespamgr / subprocess.go
old mode 100644 (file)
new mode 100755 (executable)
similarity index 79%
rename from cmd/vesmgr/subprocess.go
rename to cmd/vespamgr/subprocess.go
index 0c84312..0ea78cf
@@ -25,13 +25,13 @@ import (
        "os/exec"
 )
 
-type cmdRunner struct {
+type CommandRunner struct {
        exe  string
        args []string
        cmd  *exec.Cmd
 }
 
-func (r *cmdRunner) run(result chan error) {
+func (r *CommandRunner) Run(result chan error) {
        r.cmd = exec.Command(r.exe, r.args...)
        r.cmd.Stdout = os.Stdout
        r.cmd.Stderr = os.Stderr
@@ -45,11 +45,14 @@ func (r *cmdRunner) run(result chan error) {
        }()
 }
 
-func (r *cmdRunner) kill() error {
-       return r.cmd.Process.Kill()
+func (r *CommandRunner) Kill() error {
+       if r.cmd != nil {
+               return r.cmd.Process.Kill()
+       }
+       return nil
 }
 
-func makeRunner(exe string, arg ...string) cmdRunner {
-       r := cmdRunner{exe: exe, args: arg}
+func NewCommandRunner(exe string, arg ...string) *CommandRunner {
+       r := &CommandRunner{exe: exe, args: arg}
        return r
 }