| 38 | } |
| 39 | |
| 40 | func (this *APIStream) Start() { |
| 41 | events.OnKey(events.EventQuit, this, func() { |
| 42 | this.isQuiting = true |
| 43 | if this.cancelFunc != nil { |
| 44 | this.cancelFunc() |
| 45 | } |
| 46 | }) |
| 47 | for { |
| 48 | if this.isQuiting { |
| 49 | return |
| 50 | } |
| 51 | err := this.loop() |
| 52 | if err != nil { |
| 53 | if rpc.IsConnError(err) { |
| 54 | remotelogs.Debug("API_STREAM", err.Error()) |
| 55 | } else { |
| 56 | remotelogs.Warn("API_STREAM", err.Error()) |
| 57 | } |
| 58 | time.Sleep(10 * time.Second) |
| 59 | continue |
| 60 | } |
| 61 | time.Sleep(1 * time.Second) |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | func (this *APIStream) loop() error { |
| 66 | rpcClient, err := rpc.SharedRPC() |