remove unnecessary checks (#7903)
This commit is contained in:
@@ -81,8 +81,6 @@ func Start(envMap map[string]any) {
|
||||
// retry only if oCIS server exited with code > 0
|
||||
// -1 exit code means that the process was killed by a signal (syscall.SIGINT)
|
||||
if status.ExitStatus() > 0 && !stopSignal {
|
||||
waitUntilCompleteShutdown()
|
||||
|
||||
log.Println(fmt.Sprintf("oCIS server exited with code %v", status.ExitStatus()))
|
||||
|
||||
// retry to start oCIS server
|
||||
@@ -99,9 +97,9 @@ func Start(envMap map[string]any) {
|
||||
}
|
||||
|
||||
func Stop() {
|
||||
log.Println("Stopping oCIS server...")
|
||||
stopSignal = true
|
||||
|
||||
// SIGINT allows oCIS server to gracefully shutdown
|
||||
err := cmd.Process.Signal(syscall.SIGINT)
|
||||
if err != nil {
|
||||
if !strings.HasSuffix(err.Error(), "process already finished") {
|
||||
@@ -109,7 +107,6 @@ func Stop() {
|
||||
}
|
||||
}
|
||||
cmd.Process.Wait()
|
||||
waitUntilCompleteShutdown()
|
||||
}
|
||||
|
||||
func WaitForConnection() bool {
|
||||
@@ -150,29 +147,10 @@ func WaitForConnection() bool {
|
||||
}
|
||||
}
|
||||
|
||||
func waitUntilCompleteShutdown() {
|
||||
timeout := 30 * time.Second
|
||||
startTime := time.Now()
|
||||
|
||||
c := exec.Command("sh", "-c", "ps ax | grep 'ocis server' | grep -v grep | awk '{print $1}'")
|
||||
output, err := c.CombinedOutput()
|
||||
if err != nil {
|
||||
log.Println(err.Error())
|
||||
}
|
||||
for strings.TrimSpace(string(output)) != "" {
|
||||
output, _ = c.CombinedOutput()
|
||||
|
||||
if time.Since(startTime) >= timeout {
|
||||
log.Println(fmt.Sprintf("Unable to kill oCIS server after %v seconds", int64(timeout.Seconds())))
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func Restart(envMap map[string]any) bool {
|
||||
log.Println("Restarting oCIS server...")
|
||||
Stop()
|
||||
|
||||
log.Println("Restarting oCIS server...")
|
||||
common.Wg.Add(1)
|
||||
go Start(envMap)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user