Spawner ready

Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
This commit is contained in:
pancho horrillo
2019-10-10 11:49:03 +02:00
parent 958175c59a
commit a39e0f6605
4 changed files with 116 additions and 2 deletions
+13 -2
View File
@@ -5,18 +5,29 @@ import (
"os"
"os/exec"
"github.com/google/shlex"
"github.com/BBVA/kapow/internal/server/model"
)
func spawn(h *model.Handler, out io.Writer) error {
cmd := exec.Command(h.Route.Entrypoint)
args, err := shlex.Split(h.Route.Entrypoint)
if err != nil {
return err
}
if h.Route.Command != "" {
args = append(args, h.Route.Command)
}
cmd := exec.Command(args[0], args[1:]...)
if out != nil {
cmd.Stdout = out
}
cmd.Env = append(os.Environ(), "KAPOW_URL=http://localhost:8081")
cmd.Env = append(cmd.Env, "KAPOW_HANDLER_ID="+h.ID)
err := cmd.Run()
err = cmd.Run()
return err
}