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

Loading…
Cancel
Save