fix: remove supervisord start (blocks forever with -n), use state for skip check
This commit is contained in:
parent
938aa168b3
commit
a6359beb61
1 changed files with 13 additions and 11 deletions
|
|
@ -82,9 +82,18 @@ func InstallNode(node state.Node, apiToken, apiHost, labels string) error {
|
||||||
fmt.Printf("[%s] Configuring NGINX module...\n", node.Name)
|
fmt.Printf("[%s] Configuring NGINX module...\n", node.Name)
|
||||||
exec.Command("bash", filepath.Join(DeployTo, "pick-module.sh")).Run()
|
exec.Command("bash", filepath.Join(DeployTo, "pick-module.sh")).Run()
|
||||||
|
|
||||||
// 6. Register node (skip if already registered from previous run)
|
// 6. Register node — skip if this node was previously deployed
|
||||||
nodeYaml := filepath.Join(DeployTo, "etc", "wallarm", "node.yaml")
|
existingState, _ := state.Load()
|
||||||
if _, err := os.Stat(nodeYaml); err == nil {
|
alreadyRegistered := false
|
||||||
|
if existingState != nil {
|
||||||
|
for _, n := range existingState.Nodes {
|
||||||
|
if n.Name == node.Name {
|
||||||
|
alreadyRegistered = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if alreadyRegistered {
|
||||||
fmt.Printf("[%s] Already registered, skipping.\n", node.Name)
|
fmt.Printf("[%s] Already registered, skipping.\n", node.Name)
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("[%s] Registering node (this may take 30-60s)...\n", node.Name)
|
fmt.Printf("[%s] Registering node (this may take 30-60s)...\n", node.Name)
|
||||||
|
|
@ -124,14 +133,7 @@ func InstallNode(node state.Node, apiToken, apiHost, labels string) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 7. Stop our temporary NGINX, start Wallarm via supervisord
|
// 7. Move /opt/wallarm → /opt/fw/{name}/wallarm
|
||||||
exec.Command("pkill", "-f", filepath.Join(DeployTo, "nginx")).Run()
|
|
||||||
supervisorCmd := exec.Command("bash", filepath.Join(DeployTo, "supervisord.sh"), "start")
|
|
||||||
supervisorCmd.Dir = DeployTo
|
|
||||||
supervisorCmd.Run()
|
|
||||||
fmt.Printf("[%s] Services started.\n", node.Name)
|
|
||||||
|
|
||||||
// 8. Move /opt/wallarm → /opt/fw/{name}/wallarm
|
|
||||||
os.MkdirAll(filepath.Join(BaseDir, node.Name), 0755)
|
os.MkdirAll(filepath.Join(BaseDir, node.Name), 0755)
|
||||||
os.RemoveAll(instanceDir)
|
os.RemoveAll(instanceDir)
|
||||||
os.Rename(DeployTo, instanceDir)
|
os.Rename(DeployTo, instanceDir)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue