fix: keep env.list alive with background goroutine during setup.sh
This commit is contained in:
parent
0922102226
commit
8484ca46a7
1 changed files with 18 additions and 6 deletions
|
|
@ -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()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue