Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
amrita-shrestha committed Jan 9, 2025
1 parent ae7691a commit 27074ac
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions tests/ociswrapper/ocis/ocis.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var EnvConfigs = []string{}
var runningServices = make(map[string]int)

func Start(envMap []string) {
StartService("", envMap)
StartService("", envMap)
}

func Stop() (bool, string) {
Expand Down Expand Up @@ -57,10 +57,16 @@ func Restart(envMap []string) (bool, string) {
}

func IsOcisRunning() bool {
if runningServices["ocis"] > 0 {
return true
}
return false
if runningServices["ocis"] == 0 {
return false
}

_, err := os.FindProcess(runningServices["ocis"])
if err != nil {
delete(runningServices, "ocis")
return false
}
return true
}

func waitAllServices(startTime time.Time, timeout time.Duration) {
Expand Down Expand Up @@ -239,7 +245,7 @@ func StartService(service string, envMap []string) {
}

for listservice, pid := range runningServices {
log.Println(fmt.Sprintf("Service started: %s with process and id: %v\n", listservice, pid))
log.Println(fmt.Sprintf("Service started: %s with process and id: %v\n", listservice, pid))
}

// Read the logs when the 'ocis server' command is running
Expand Down Expand Up @@ -308,15 +314,11 @@ func StopService(service string) (bool, string) {
pKillError := process.Signal(syscall.SIGINT)
if pKillError != nil {
return false, fmt.Sprintf("Failed to stop service with process id %d", pid)
}
} else {
delete(runningServices, service)

_, waitErr := process.Wait()
if waitErr != nil {
return false, fmt.Sprintf("Error waiting for process to exit: %v\n", waitErr)
}
delete(runningServices, service)
log.Println(fmt.Sprintf("oCIS service %s has been stopped successfully", service))
}

// service takes 30s time to sync
time.Sleep(30 * time.Second)
return true, fmt.Sprintf("Service %s stopped successfully", service)
}

0 comments on commit 27074ac

Please sign in to comment.