Skip to content

Commit

Permalink
env RELAY_SCYLLA_NODES
Browse files Browse the repository at this point in the history
setup cleanup
  • Loading branch information
brianolson committed Dec 11, 2024
1 parent 8743ff0 commit 6026f75
Showing 1 changed file with 30 additions and 27 deletions.
57 changes: 30 additions & 27 deletions cmd/bigsky/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,10 @@ func run(args []string) error {
Value: false,
},
&cli.StringSliceFlag{
Name: "scylla-carstore",
Usage: "scylla server addresses for storage backend, probably comma separated, urfave/cli is unclear",
Value: &cli.StringSlice{},
Name: "scylla-carstore",
Usage: "scylla server addresses for storage backend, comma separated",
Value: &cli.StringSlice{},
EnvVars: []string{"RELAY_SCYLLA_NODES"},
},
}

Expand Down Expand Up @@ -321,48 +322,50 @@ func runBigsky(cctx *cli.Context) error {
return err
}

slog.Info("setting up main database")
dburl := cctx.String("db-url")
slog.Info("setting up main database", "url", dburl)
db, err := cliutil.SetupDatabase(dburl, cctx.Int("max-metadb-connections"))
if err != nil {
return err
}

slog.Info("setting up carstore database")
csdburl := cctx.String("carstore-db-url")
csdb, err := cliutil.SetupDatabase(csdburl, cctx.Int("max-carstore-connections"))
if err != nil {
return err
}

if cctx.Bool("db-tracing") {
if err := db.Use(tracing.NewPlugin()); err != nil {
return err
}
if err := csdb.Use(tracing.NewPlugin()); err != nil {
return err
}
}

csdirs := []string{csdir}
if paramDirs := cctx.StringSlice("carstore-shard-dirs"); len(paramDirs) > 0 {
csdirs = paramDirs
}

for _, csd := range csdirs {
if err := os.MkdirAll(filepath.Dir(csd), os.ModePerm); err != nil {
return err
}
}

var cstore carstore.CarStore
scyllaAddrs := cctx.StringSlice("scylla-carstore")
sqliteStore := cctx.Bool("ex-sqlite-carstore")
if len(scyllaAddrs) != 0 {
slog.Info("starting scylla carstore", "addrs", scyllaAddrs)
cstore, err = carstore.NewScyllaStore(scyllaAddrs, "cs")
} else if cctx.Bool("ex-sqlite-carstore") {
} else if sqliteStore {
slog.Info("starting sqlite carstore", "dir", csdir)
cstore, err = carstore.NewSqliteStore(csdir)
} else {
// make standard FileCarStore
csdburl := cctx.String("carstore-db-url")
slog.Info("setting up carstore database", "url", csdburl)
csdb, err := cliutil.SetupDatabase(csdburl, cctx.Int("max-carstore-connections"))
if err != nil {
return err
}
if cctx.Bool("db-tracing") {
if err := csdb.Use(tracing.NewPlugin()); err != nil {
return err
}
}
csdirs := []string{csdir}
if paramDirs := cctx.StringSlice("carstore-shard-dirs"); len(paramDirs) > 0 {
csdirs = paramDirs
}

for _, csd := range csdirs {
if err := os.MkdirAll(filepath.Dir(csd), os.ModePerm); err != nil {
return err
}
}
cstore, err = carstore.NewCarStore(csdb, csdirs)
}

Expand Down

0 comments on commit 6026f75

Please sign in to comment.