-
Notifications
You must be signed in to change notification settings - Fork 4k
Expand file tree
/
Copy pathentrypoint.go
More file actions
59 lines (45 loc) · 1.4 KB
/
Copy pathentrypoint.go
File metadata and controls
59 lines (45 loc) · 1.4 KB
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
52
53
54
55
56
57
58
59
package main
import (
"fmt"
"github.com/urfave/cli/v2"
altda "github.com/ethereum-optimism/optimism/op-alt-da"
"github.com/ethereum-optimism/optimism/op-service/ctxinterrupt"
"github.com/ethereum-optimism/optimism/op-service/log/logcli"
)
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 := logcli.ReadCLIConfig(cliCtx)
l := logcli.NewLogger(logcli.AppOut(cliCtx), logCfg)
logcli.SetGlobalLogHandler(l.Handler())
l.Info("Initializing AltDA server...")
var store altda.KVStore
if cfg.FileStoreEnabled() {
l.Info("Using file storage", "path", cfg.FileStoreDirPath)
store = NewFileStore(cfg.FileStoreDirPath)
} else if cfg.S3Enabled() {
l.Info("Using S3 storage", "bucket", cfg.S3Config().Bucket)
s3, err := NewS3Store(cfg.S3Config())
if err != nil {
return fmt.Errorf("failed to create S3 store: %w", err)
}
store = s3
}
server := altda.NewDAServer(cliCtx.String(ListenAddrFlagName), cliCtx.Int(PortFlagName), store, l, cfg.UseGenericComm)
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)
}
}()
return ctxinterrupt.Wait(cliCtx.Context)
}