Skip to content

Commit

Permalink
Merge pull request #511 from brotherlogic/quieter
Browse files Browse the repository at this point in the history
quieter
  • Loading branch information
brotherlogic committed Jul 14, 2020
2 parents 4b8b345 + 2cb5eab commit 8a3fd83
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions goserverapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -1408,15 +1408,13 @@ func (s *GoServer) registerServer(IP string, servername string, external bool, v
}

func (s *GoServer) runElection(elected chan error, complete chan bool) {
s.Log(fmt.Sprintf("Running election"))
command := exec.Command("etcdctl", "elect", s.Registry.Name, s.Registry.Identifier)
out, _ := command.StdoutPipe()
if out != nil {
scanner := bufio.NewScanner(out)
go func() {
for scanner != nil && scanner.Scan() {
text := scanner.Text()
s.Log(fmt.Sprintf("HERE %v", text))
// Expect something like registry.name/key
if strings.HasPrefix(text, s.Registry.Name) {
elected <- nil
Expand All @@ -1435,11 +1433,10 @@ func (s *GoServer) runElection(elected chan error, complete chan bool) {
for scanner != nil && scanner.Scan() {
text := scanner.Text()
s.Log(fmt.Sprintf("ERR %v", text))
// Expect something like registry.name/key
if strings.HasPrefix(text, s.Registry.Name) {
elected <- nil
} else {
elected <- fmt.Errorf("Unable to elect: %v", scanner.Text())
elected <- fmt.Errorf("Unable to from err elect: %v", scanner.Text())
}
}
out2.Close()
Expand All @@ -1451,7 +1448,6 @@ func (s *GoServer) runElection(elected chan error, complete chan bool) {
if err != nil {
s.Log(fmt.Sprintf("Error starting command: %v", err))
}
s.Log(fmt.Sprintf("Started command, waiting for complete"))
<-complete
command.Process.Kill()

Expand Down

0 comments on commit 8a3fd83

Please sign in to comment.