First cut to spawner

Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
This commit is contained in:
pancho horrillo
2019-10-09 18:27:11 +02:00
parent 007923de8a
commit d0764f07a4
2 changed files with 147 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
package user
import (
"io"
"os"
"os/exec"
"github.com/BBVA/kapow/internal/server/model"
)
func spawn(h *model.Handler, out io.Writer) error {
cmd := exec.Command(h.Route.Entrypoint)
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()
return err
}