Browse Source

Put cmd.Start() and cmd.Wait() in a loop so keybase restarts if it dies

main
Sam 6 years ago
parent
commit
354fa145e1
  1. 4
      chatIn.go

4
chatIn.go

@ -155,9 +155,10 @@ func getNewMessages(k Keybase, c chan<- ChatIn, execOptions []string) {
} }
keybaseListen := exec.Command(k.Path, execCommand...) keybaseListen := exec.Command(k.Path, execCommand...)
keybaseOutput, _ := keybaseListen.StdoutPipe() keybaseOutput, _ := keybaseListen.StdoutPipe()
for {
keybaseListen.Start() keybaseListen.Start()
scanner := bufio.NewScanner(keybaseOutput) scanner := bufio.NewScanner(keybaseOutput)
go func(scanner *bufio.Scanner, c chan<- ChatIn) { go func(scanner *bufio.Scanner, c chan<- ChatIn) {
var jsonData ChatIn var jsonData ChatIn
for scanner.Scan() { for scanner.Scan() {
@ -166,6 +167,7 @@ func getNewMessages(k Keybase, c chan<- ChatIn, execOptions []string) {
} }
}(scanner, c) }(scanner, c)
keybaseListen.Wait() keybaseListen.Wait()
}
} }
// Run() runs keybase chat api-listen, and passes incoming messages to the message handler func // Run() runs keybase chat api-listen, and passes incoming messages to the message handler func

Loading…
Cancel
Save