MCPcopy Create free account
hub / github.com/ethstorage/es-node / EsNodeMain

Function EsNodeMain

cmd/es-node/main.go:152–215  ·  view source on GitHub ↗
(ctx *cli.Context)

Source from the content-addressed store, hash-verified

150}
151
152func EsNodeMain(ctx *cli.Context) error {
153 lg.Info("Configuring EthStorage Node")
154 lgCfg := log.ReadCLIConfig(ctx)
155 lg.Info("Loading log config", "config", lgCfg)
156 clog := log.NewLogger(lgCfg)
157 cfg, err := NewConfig(ctx, clog)
158 if err != nil {
159 lg.Error("Unable to create the rollup node config", "error", err)
160 return err
161 }
162
163 var m metrics.Metricer = metrics.NoopMetrics
164 if cfg.Metrics.Enabled {
165 m = metrics.NewMetrics("default")
166 }
167 n, err := node.New(context.Background(), cfg, clog, VersionWithMeta, m)
168 if err != nil {
169 clog.Error("Unable to create the storage node", "error", err)
170 return err
171 }
172 clog.Info("Starting storage node", "version", VersionWithMeta)
173
174 if err := n.Start(context.Background(), cfg); err != nil {
175 clog.Error("Unable to start rollup node", "error", err)
176 return err
177 }
178 defer n.Close()
179
180 m.RecordInfo(VersionWithMeta)
181 m.RecordUp()
182 // TODO: heartbeat
183 if cfg.Pprof.Enabled {
184 pprofCtx, pprofCancel := context.WithCancel(context.Background())
185 go func() {
186 clog.Info("pprof server started", "addr", net.JoinHostPort(cfg.Pprof.ListenAddr, strconv.Itoa(cfg.Pprof.ListenPort)))
187 if err := oppprof.ListenAndServe(pprofCtx, cfg.Pprof.ListenAddr, cfg.Pprof.ListenPort); err != nil {
188 clog.Error("error starting pprof", "err", err)
189 }
190 }()
191 defer pprofCancel()
192 }
193
194 clog.Info("Storage node started")
195
196 // Run simple sync test
197 start := ctx.GlobalUint64(flags.TestSimpleSyncStartFlag.Name)
198 end := ctx.GlobalUint64(flags.TestSimpleSyncEndFlag.Name)
199 if end > start {
200 lg.Info("Start force sync", "start", start, "end", end)
201 n.RequestL2Range(context.Background(), start, end)
202 }
203
204 interruptChannel := make(chan os.Signal, 1)
205 signal.Notify(interruptChannel, []os.Signal{
206 os.Interrupt,
207 os.Kill,
208 syscall.SIGTERM,
209 syscall.SIGQUIT,

Callers

nothing calls this directly

Calls 11

RecordInfoMethod · 0.95
RecordUpMethod · 0.95
ReadCLIConfigFunction · 0.92
NewLoggerFunction · 0.92
NewMetricsFunction · 0.92
NewFunction · 0.92
NewConfigFunction · 0.70
CloseMethod · 0.65
ErrorMethod · 0.45
StartMethod · 0.45
RequestL2RangeMethod · 0.45

Tested by

no test coverage detected