fix: source env.list before register, 60s timeout

This commit is contained in:
admin 2026-08-01 19:52:29 +00:00
parent 452976ab43
commit 842024a6ea

View file

@ -1,6 +1,7 @@
package native package native
import ( import (
"context"
"fmt" "fmt"
"os" "os"
"os/exec" "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() exec.Command("bash", filepath.Join(DeployTo, "pick-module.sh")).Run()
fmt.Printf("[%s] Registering node...\n", node.Name) fmt.Printf("[%s] Registering node...\n", node.Name)
registerCmd := exec.Command(filepath.Join(DeployTo, "register-node"), ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
"job:register", defer cancel()
"-token", apiToken, registerCmd := exec.CommandContext(ctx, "bash", "-c",
"-host", apiHost, 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 registerCmd.Dir = DeployTo
out, regErr := registerCmd.CombinedOutput() out, regErr := registerCmd.CombinedOutput()