MCPcopy
hub / github.com/canopy-network/canopy / Start

Function Start

cmd/cli/cli.go:81–124  ·  view source on GitHub ↗

Start() is the entrypoint of the application

()

Source from the content-addressed store, hash-verified

79
80// Start() is the entrypoint of the application
81func Start() {
82 // start the validator TCP proxy (if configured)
83 proxy := lib.NewValidatorTCPProxy(config.ValidatorTCPProxy, l)
84 if err := proxy.Start(); err != nil {
85 l.Fatal(err.Error())
86 }
87 // initialize and start the metrics server
88 metrics := lib.NewMetricsServer(validatorKey.PublicKey().Address(), float64(config.ChainId), rpc.SoftwareVersion, config.MetricsConfig, l)
89 // create a new database object from the config
90 db, err := store.New(config, metrics, l)
91 if err != nil {
92 l.Fatal(err.Error())
93 }
94 // log the validator identity
95 l.Infof("Using identity: Address: %s | PublicKey: %s",
96 validatorKey.PublicKey().Address().String(), validatorKey.PublicKey().String())
97 // initialize the state machine
98 sm, err := fsm.New(config, db, nil, metrics, l)
99 if err != nil {
100 l.Fatal(err.Error())
101 }
102 // create a new instance of the application
103 app, err := controller.New(sm, config, validatorKey, metrics, l)
104 if err != nil {
105 l.Fatal(err.Error())
106 }
107 // initialize the rpc server
108 rpcServer := rpc.NewServer(app, config, l)
109 // start the metrics server
110 metrics.Start()
111 // start the application
112 app.Start()
113 // start the rpc server
114 rpcServer.Start()
115 // block until a kill signal is received
116 waitForKill()
117 proxy.Stop()
118 // gracefully stop the app
119 app.Stop()
120 // gracefully stop the metrics server
121 metrics.Stop()
122 // exit
123 os.Exit(0)
124}
125
126// waitForKill() blocks until a kill signal is received
127func waitForKill() {

Callers 2

mainFunction · 0.92
cli.goFile · 0.85

Calls 15

StartMethod · 0.95
StartMethod · 0.95
StopMethod · 0.95
NewValidatorTCPProxyFunction · 0.92
NewMetricsServerFunction · 0.92
NewFunction · 0.92
NewFunction · 0.92
NewFunction · 0.92
NewServerFunction · 0.92
waitForKillFunction · 0.85
FatalMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected