-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.go
51 lines (35 loc) · 1.08 KB
/
entrypoint.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"fmt"
"github.com/urfave/cli/v2"
availService "avail-alt-da-server/service"
oplog "github.com/ethereum-optimism/optimism/op-service/log"
"github.com/ethereum-optimism/optimism/op-service/opio"
)
func StartDAServer(cliCtx *cli.Context) error {
if err := CheckRequired(cliCtx); err != nil {
return err
}
cfg := ReadCLIConfig(cliCtx)
if err := cfg.Check(); err != nil {
return err
}
logCfg := oplog.ReadCLIConfig(cliCtx)
l := oplog.NewLogger(oplog.AppOut(cliCtx), logCfg)
oplog.SetGlobalLogHandler(l.Handler())
l.Info("Initializing Alt DA DA server...")
availService := availService.NewAvailService(cfg.RPC, cfg.Seed, cfg.AppId, cfg.Timeout, l)
server := NewAvailDAServer(cliCtx.String(ListenAddrFlagName), cliCtx.Int(PortFlagName), availService, l, true)
if err := server.Start(); err != nil {
return fmt.Errorf("failed to start the DA server")
} else {
l.Info("Started DA Server")
}
defer func() {
if err := server.Stop(); err != nil {
l.Error("failed to stop DA server", "err", err)
}
}()
opio.BlockOnInterrupts()
return nil
}