feat: patchelf ELF binaries per instance for true multi-node
This commit is contained in:
parent
6c8b9dc166
commit
aeb8be3ebc
1 changed files with 17 additions and 7 deletions
|
|
@ -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()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue