Revert "wrapper fix: kill all opencloud and nats processes"

This reverts commit 62674c71cf.
This commit is contained in:
Ralf Haferkamp
2026-04-28 16:22:33 +02:00
committed by Ralf Haferkamp
parent 32549ae0e1
commit f0e9e10fa7

View File

@@ -121,10 +121,19 @@ func Stop() (bool, string) {
return true, "OpenCloud server is not running"
}
exec.Command("sh", "-c", "pkill -9 -f 'opencloud|nats-server' 2>/dev/null || true").Run()
err := cmd.Process.Signal(syscall.SIGINT)
if err != nil {
if !strings.HasSuffix(err.Error(), "process already finished") {
log.Fatalln(err)
} else {
return true, "OpenCloud server is already stopped"
}
}
cmd.Process.Wait()
success, message := waitUntilCompleteShutdown()
cmd = nil
return true, "OpenCloud server stopped successfully"
return success, message
}
func Restart(envMap []string) (bool, string) {
@@ -144,7 +153,24 @@ func IsOpencloudRunning() bool {
return false
}
func waitAllServices(startTime time.Time, timeout time.Duration) {
timeoutS := timeout * time.Second
c := exec.Command(config.Get("bin"), "list")
_, err := c.CombinedOutput()
if err != nil {
if time.Since(startTime) <= timeoutS {
time.Sleep(500 * time.Millisecond)
waitAllServices(startTime, timeout)
}
return
}
log.Println("All services are up")
}
func WaitForConnection() (bool, string) {
waitAllServices(time.Now(), 30)
transport := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
@@ -188,7 +214,7 @@ func WaitForConnection() (bool, string) {
}
func waitUntilCompleteShutdown() (bool, string) {
timeout := 45 * time.Second
timeout := 30 * time.Second
startTime := time.Now()
c := exec.Command("sh", "-c", "ps ax | grep 'opencloud server' | grep -v grep | awk '{print $1}'")