MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / Run

Method Run

pkg/component/component.go:396–417  ·  view source on GitHub ↗

Run starts the component, and returns when a stop signal has been received by the process.

()

Source from the content-addressed store, hash-verified

394
395// Run starts the component, and returns when a stop signal has been received by the process.
396func (c *Component) Run() error {
397 defer c.Close()
398
399 if err := c.Start(); err != nil {
400 return err
401 }
402
403 defer func() {
404 c.logger.Debug("Leaving cluster...")
405 if err := c.cluster.Leave(); err != nil {
406 c.logger.WithError(err).Error("Could not leave cluster")
407 }
408 c.logger.Debug("Left cluster")
409 }()
410
411 signal.Notify(c.terminationSignals, os.Interrupt, syscall.SIGTERM)
412
413 sig := <-c.terminationSignals
414 fmt.Println()
415 c.logger.WithField("signal", sig).Info("Received signal, exiting...")
416 return nil
417}
418
419// Close closes the server.
420func (c *Component) Close() {

Callers

nothing calls this directly

Implementers 1

Componentpkg/component/component.go

Calls 9

CloseMethod · 0.95
StartMethod · 0.95
DebugMethod · 0.65
LeaveMethod · 0.65
ErrorMethod · 0.65
WithErrorMethod · 0.65
NotifyMethod · 0.65
InfoMethod · 0.65
WithFieldMethod · 0.65

Tested by

no test coverage detected