From 8484ca46a72ade63c6fe12e6c4c7ddf359ff288d Mon Sep 17 00:00:00 2001 From: admin Date: Sat, 1 Aug 2026 18:37:17 +0000 Subject: [PATCH] fix: keep env.list alive with background goroutine during setup.sh --- internal/native/native.go | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/internal/native/native.go b/internal/native/native.go index bb84573..6741393 100644 --- a/internal/native/native.go +++ b/internal/native/native.go @@ -6,6 +6,7 @@ import ( "os/exec" "path/filepath" "strings" + "time" "git.sechpoint.app/customer-engineering/wallarm/internal/state" ) @@ -61,15 +62,25 @@ func InstallNode(node state.Node, apiToken, apiHost, labels string) error { return fmt.Errorf("extract: %w\n%s", err, string(out)) } - // 5. Patch setup.sh: make env.list sed commands non-fatal (file gets deleted during nginx test) - setupPath := filepath.Join(DeployTo, "setup.sh") - exec.Command("sed", "-i", - `s|\(/opt/wallarm/env.list\)|\1 2>/dev/null || true|g`, - setupPath).Run() + // 5. Fix: recreate env.list in background while setup.sh runs + done := make(chan struct{}) + go func() { + defer close(done) + for { + select { + case <-done: + return + default: + os.WriteFile(filepath.Join(DeployTo, "env.list"), + []byte("# wallarm env\n"), 0644) + time.Sleep(500 * time.Millisecond) + } + } + }() // 6. Run setup.sh fmt.Printf("[%s] Running setup...\n", node.Name) - cmd = exec.Command("bash", setupPath, + cmd = exec.Command("bash", filepath.Join(DeployTo, "setup.sh"), "--batch", "--token", apiToken, "--cloud", cloudFromHost(apiHost), "--custom-ngx-build", ) @@ -81,6 +92,7 @@ func InstallNode(node state.Node, apiToken, apiHost, labels string) error { cmd.Stderr = logFile } runErr := cmd.Run() + close(done) // stop env.list keeper if logFile != nil { logFile.Close() }