diff --git a/internal/native/native.go b/internal/native/native.go index 61fbe8c..0a1c75c 100644 --- a/internal/native/native.go +++ b/internal/native/native.go @@ -1,6 +1,7 @@ package native import ( + "context" "fmt" "os" "os/exec" @@ -83,11 +84,11 @@ func InstallNode(node state.Node, apiToken, apiHost, labels string) error { exec.Command("bash", filepath.Join(DeployTo, "pick-module.sh")).Run() fmt.Printf("[%s] Registering node...\n", node.Name) - registerCmd := exec.Command(filepath.Join(DeployTo, "register-node"), - "job:register", - "-token", apiToken, - "-host", apiHost, - ) + ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second) + defer cancel() + registerCmd := exec.CommandContext(ctx, "bash", "-c", + fmt.Sprintf("source %s/env.list 2>/dev/null; %s/register-node job:register -token '%s' -host '%s'", + DeployTo, DeployTo, apiToken, apiHost)) registerCmd.Dir = DeployTo out, regErr := registerCmd.CombinedOutput()