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)
|
||||
exec.Command("bash", filepath.Join(DeployTo, "pick-module.sh")).Run()
|
||||
|
||||
// 6. Register node (skip if already registered from previous run)
|
||||
nodeYaml := filepath.Join(DeployTo, "etc", "wallarm", "node.yaml")
|
||||
if _, err := os.Stat(nodeYaml); err == nil {
|
||||
// 6. Register node — skip if this node was previously deployed
|
||||
existingState, _ := state.Load()
|
||||
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)
|
||||
} else {
|
||||
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
|
||||
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
|
||||
// 7. Move /opt/wallarm → /opt/fw/{name}/wallarm
|
||||
os.MkdirAll(filepath.Join(BaseDir, node.Name), 0755)
|
||||
os.RemoveAll(instanceDir)
|
||||
os.Rename(DeployTo, instanceDir)
|
||||
|
|
|
|||
Loading…
Reference in a new issue