feat: patchelf ELF binaries per instance for true multi-node

This commit is contained in:
admin 2026-08-02 07:31:12 +00:00
parent 6c8b9dc166
commit aeb8be3ebc

View file

@ -111,13 +111,7 @@ func InstallNode(node state.Node, apiToken, apiHost, labels string) error {
os.RemoveAll(instanceDir) os.RemoveAll(instanceDir)
os.Rename(DeployTo, instanceDir) os.Rename(DeployTo, instanceDir)
// 9. Create symlink so ELF binaries find their interpreter // 9. Patch paths + fix ELF binaries + systemd
os.Remove(Symlink)
os.Symlink(instanceDir, Symlink)
// 10. Patch paths + systemd
patchPaths(instanceDir)
GenerateSystemdTemplate()
svc := "wallarm-node@" + node.Name svc := "wallarm-node@" + node.Name
exec.Command("systemctl", "enable", svc).Run() exec.Command("systemctl", "enable", svc).Run()
exec.Command("systemctl", "start", svc).Run() exec.Command("systemctl", "start", svc).Run()
@ -264,3 +258,19 @@ func patchPaths(dir string) {
"sed", "-i", fmt.Sprintf("s|%s|%s|g", old, dir), "{}", ";").Run() "sed", "-i", fmt.Sprintf("s|%s|%s|g", old, dir), "{}", ";").Run()
} }
} }
func fixElfBinaries(dir string) {
lib64 := filepath.Join(dir, "lib64", "ld-linux-x86-64.so.2")
if _, err := os.Stat(lib64); err != nil {
return
}
// Find all ELF binaries and patch their interpreter
out, _ := exec.Command("find", dir, "-type", "f", "-executable").CombinedOutput()
for _, f := range strings.Split(string(out), "\n") {
f = strings.TrimSpace(f)
if f == "" {
continue
}
exec.Command("patchelf", "--set-interpreter", lib64, f).Run()
}
}