| 238 | } |
| 239 | |
| 240 | func (n *Nylon) Start() error { |
| 241 | n.Log.Info("init modules complete") |
| 242 | |
| 243 | n.Log.Info("Nylon has been initialized. To gracefully exit, send SIGINT or Ctrl+C.") |
| 244 | |
| 245 | c := make(chan os.Signal, 1) |
| 246 | signal.Notify(c, syscall.SIGINT, syscall.SIGTERM) |
| 247 | go func() { |
| 248 | select { |
| 249 | case _ = <-c: |
| 250 | n.Cancel(errors.New("received shutdown signal")) |
| 251 | case <-n.Context.Done(): |
| 252 | return |
| 253 | } |
| 254 | }() |
| 255 | |
| 256 | err := n.mainLoop() |
| 257 | if err != nil { |
| 258 | return err |
| 259 | } |
| 260 | return nil |
| 261 | } |
| 262 | |
| 263 | func (n *Nylon) Stop() { |
| 264 | n.cleanupOnce.Do(func() { |