Stop requires a reason to stop the server. this is to ensure that the server is not stopped accidentally. and to trace back the stopper
(logger *zap.Logger, reason string)
| 135 | // this is to ensure that the server is not stopped accidentally. |
| 136 | // and to trace back the stopper |
| 137 | func Stop(logger *zap.Logger, reason string) error { |
| 138 | // Stop the server. |
| 139 | if logger == nil { |
| 140 | return errors.New("logger is not set") |
| 141 | } |
| 142 | if cancel == nil { |
| 143 | err := errors.New("cancel function is not set") |
| 144 | LogError(logger, err, "failed stopping keploy") |
| 145 | return err |
| 146 | } |
| 147 | |
| 148 | if reason == "" { |
| 149 | err := errors.New("cannot stop keploy without a reason") |
| 150 | LogError(logger, err, "failed stopping keploy") |
| 151 | return err |
| 152 | } |
| 153 | |
| 154 | logger.Info("stopping Keploy", zap.String("reason", reason)) |
| 155 | ExecCancel() |
| 156 | return nil |
| 157 | } |
| 158 | |
| 159 | func ExecCancel() { |
| 160 | cancel() |