diff --git a/cmd/server/kodata/.gitkeep b/cmd/server/kodata/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/impl/todo_impl.go b/impl/todo_impl.go index a61ae78..0f4f24c 100644 --- a/impl/todo_impl.go +++ b/impl/todo_impl.go @@ -29,18 +29,22 @@ func init() { logger, _ := zap.NewDevelopment() defer logger.Sync() log = logger.Sugar() - cwd, _ := os.Getwd() - dataDir := path.Join(cwd, "data") - if _, err := os.Stat(dataDir); err != nil && os.IsNotExist(err) { - if err := os.MkdirAll(dataDir, os.ModePerm); err != nil { - log.Fatal("error creating data directory,%s", err) + //KO_DATA_PATH will be available only when running with ko container + dataDir, ok := os.LookupEnv("KO_DATA_PATH") + if !ok { + cwd, _ := os.Getwd() + dataDir = path.Join(cwd, "data") + if _, err := os.Stat(dataDir); err != nil && os.IsNotExist(err) { + if err := os.MkdirAll(dataDir, os.ModePerm); err != nil { + log.Fatal("error creating data directory,%s", err) + } } } dbFile := path.Join(dataDir, "sequence.db") log.Infof("Data File:%s", dbFile) sc, err = utils.NewSequence(fmt.Sprintf("file://%s?cache=shared", dbFile)) if err != nil { - log.Fatal("error initializing sequence DB,%s", err) + log.Fatalf("error initializing sequence DB,%s", err) } }