(cancel context.CancelFunc)
| 73 | } |
| 74 | |
| 75 | func setupSignalHandler(cancel context.CancelFunc) { |
| 76 | c := make(chan os.Signal, 1) |
| 77 | signal.Notify(c, os.Interrupt) |
| 78 | go func() { |
| 79 | for sig := range c { |
| 80 | if sig == os.Interrupt { |
| 81 | // TODO(milas): give open conns a grace period to close gracefully |
| 82 | cancel() |
| 83 | os.Exit(0) |
| 84 | } |
| 85 | } |
| 86 | }() |
| 87 | } |
| 88 | |
| 89 | func isCobraError(err error) bool { |
| 90 | // Cobra doesn't give us a good way to distinguish between Cobra errors |