Revert "wrapper fix: kill all opencloud and nats processes"
This reverts commit 62674c71cf.
This commit is contained in:
committed by
Ralf Haferkamp
parent
32549ae0e1
commit
f0e9e10fa7
@@ -121,10 +121,19 @@ func Stop() (bool, string) {
|
|||||||
return true, "OpenCloud server is not running"
|
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
|
cmd = nil
|
||||||
return true, "OpenCloud server stopped successfully"
|
return success, message
|
||||||
}
|
}
|
||||||
|
|
||||||
func Restart(envMap []string) (bool, string) {
|
func Restart(envMap []string) (bool, string) {
|
||||||
@@ -144,7 +153,24 @@ func IsOpencloudRunning() bool {
|
|||||||
return false
|
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) {
|
func WaitForConnection() (bool, string) {
|
||||||
|
waitAllServices(time.Now(), 30)
|
||||||
|
|
||||||
transport := &http.Transport{
|
transport := &http.Transport{
|
||||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
||||||
}
|
}
|
||||||
@@ -188,7 +214,7 @@ func WaitForConnection() (bool, string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func waitUntilCompleteShutdown() (bool, string) {
|
func waitUntilCompleteShutdown() (bool, string) {
|
||||||
timeout := 45 * time.Second
|
timeout := 30 * time.Second
|
||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
|
|
||||||
c := exec.Command("sh", "-c", "ps ax | grep 'opencloud server' | grep -v grep | awk '{print $1}'")
|
c := exec.Command("sh", "-c", "ps ax | grep 'opencloud server' | grep -v grep | awk '{print $1}'")
|
||||||
|
|||||||
Reference in New Issue
Block a user