| 214 | } |
| 215 | |
| 216 | func waitUntilCompleteShutdown() (bool, string) { |
| 217 | timeout := 30 * time.Second |
| 218 | startTime := time.Now() |
| 219 | |
| 220 | c := exec.Command("sh", "-c", "ps ax | grep 'opencloud server' | grep -v grep | awk '{print $1}'") |
| 221 | output, err := c.CombinedOutput() |
| 222 | if err != nil { |
| 223 | log.Println(err.Error()) |
| 224 | } |
| 225 | for strings.TrimSpace(string(output)) != "" { |
| 226 | output, _ = c.CombinedOutput() |
| 227 | log.Println("Process found. Waiting...") |
| 228 | |
| 229 | if time.Since(startTime) >= timeout { |
| 230 | log.Println(fmt.Sprintf("Unable to kill OpenCloud server after %v seconds", int64(timeout.Seconds()))) |
| 231 | return false, "Timeout waiting for OpenCloud server to stop" |
| 232 | } |
| 233 | } |
| 234 | return true, "OpenCloud server stopped successfully" |
| 235 | } |
| 236 | |
| 237 | func RunCommand(command string, inputs []string) (int, string) { |
| 238 | logs := new(strings.Builder) |