Skip to content

Commit

Permalink
Merge pull request sclevine#178 from ChuhC/master
Browse files Browse the repository at this point in the history
resolve a race
  • Loading branch information
sclevine committed Jan 31, 2019
2 parents 5e39ce1 + e057877 commit 6e6f07b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions api/internal/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ import (
"os/exec"
"runtime"
"strings"
"sync"
"syscall"
"time"
)

type Service struct {
sync.RWMutex
URLTemplate string
CmdTemplate []string
url string
Expand Down Expand Up @@ -86,7 +88,9 @@ func (s *Service) Stop() error {

s.command.Wait()
s.command = nil
s.Lock()
s.url = ""
s.Unlock()

return nil
}
Expand Down Expand Up @@ -133,7 +137,9 @@ func (s *Service) WaitForBoot(timeout time.Duration) error {

func (s *Service) checkStatus() bool {
client := &http.Client{}
s.Lock()
request, _ := http.NewRequest("GET", fmt.Sprintf("%s/status", s.url), nil)
s.Unlock()
response, err := client.Do(request)
if err != nil {
return false
Expand Down

0 comments on commit 6e6f07b

Please sign in to comment.