Better state syncing and other improvements (#24)

This commit is contained in:
Fedor Korotkov
2023-03-01 11:42:16 -05:00
committed by GitHub
parent 8df31f7c2d
commit 165662bb0a
24 changed files with 276 additions and 128 deletions
+15 -5
View File
@@ -6,8 +6,12 @@ import (
"github.com/spf13/cobra"
"go.uber.org/zap"
"os"
"path"
"path/filepath"
)
var devDataDirPath string
func NewCommand() *cobra.Command {
command := &cobra.Command{
Use: "dev",
@@ -15,6 +19,9 @@ func NewCommand() *cobra.Command {
RunE: runDev,
}
command.PersistentFlags().StringVarP(&devDataDirPath, "data-dir", "d", ".dev-data",
"path to persist data between runs")
return command
}
@@ -30,12 +37,15 @@ func runDev(cmd *cobra.Command, args []string) error {
}
}()
tempDir, err := os.MkdirTemp("", "")
if err != nil {
return err
if !filepath.IsAbs(devDataDirPath) {
pwd, err := os.Getwd()
if err != nil {
return err
}
devDataDirPath = path.Join(pwd, devDataDirPath)
}
dataDir, err := controller.NewDataDir(tempDir)
dataDir, err := controller.NewDataDir(devDataDirPath)
if err != nil {
return err
}
@@ -46,7 +56,7 @@ func runDev(cmd *cobra.Command, args []string) error {
return err
}
worker, err := worker.New(worker.WithDataDirPath(tempDir), worker.WithLogger(logger))
worker, err := worker.New(worker.WithDataDirPath(devDataDirPath), worker.WithLogger(logger))
if err != nil {
return err
}