diff --git a/cmd/linkwallet/linkwallet.go b/cmd/linkwallet/linkwallet.go index 343d48d..515829e 100644 --- a/cmd/linkwallet/linkwallet.go +++ b/cmd/linkwallet/linkwallet.go @@ -1,6 +1,7 @@ package main import ( + "flag" "log" "github.com/tardisx/linkwallet/db" @@ -10,8 +11,19 @@ import ( func main() { + var dbPath string + flag.StringVar(&dbPath, "db-path", "", "path to the database file") + flag.Parse() + + if dbPath == "" { + log.Fatal("You need to specify the path to the database file with -db-path") + } + dbh := db.DB{} - dbh.Open("badger") + err := dbh.Open(dbPath) + if err != nil { + log.Fatal(err) + } bmm := db.NewBookmarkManager(&dbh) cmm := db.NewConfigManager(&dbh) diff --git a/db/db.go b/db/db.go index d3fdd31..819559b 100644 --- a/db/db.go +++ b/db/db.go @@ -1,6 +1,7 @@ package db import ( + "fmt" "log" "github.com/tardisx/linkwallet/entity" @@ -11,16 +12,16 @@ type DB struct { store *bolthold.Store } -func (db *DB) Open(dir string) { +func (db *DB) Open(path string) error { // options := bolthold.DefaultOptions // options.Dir = dir // options.ValueDir = dir - store, err := bolthold.Open("bolt.db", 0666, nil) + store, err := bolthold.Open(path, 0666, nil) if err != nil { - panic(err) - + return fmt.Errorf("cannot open '%s' - %s", path, err) } db.store = store + return nil } func (db *DB) Close() { diff --git a/docker-compose.yml-sample b/docker-compose.yml-sample new file mode 100644 index 0000000..67ff9bb --- /dev/null +++ b/docker-compose.yml-sample @@ -0,0 +1,12 @@ +--- +version: "2.1" +services: + linkwallet: + image: tardisx/linkwallet:latest + container_name: linkwallet + command: /app/linkwallet -db-path=/data/linkwallet.db + volumes: + - /home/username/.linkwallet:/data + ports: + - 8109:8080 + restart: unless-stopped \ No newline at end of file diff --git a/version/version.go b/version/version.go index 343eff7..668ca9d 100644 --- a/version/version.go +++ b/version/version.go @@ -8,7 +8,7 @@ import ( "golang.org/x/mod/semver" ) -const Tag = "v0.0.11" +const Tag = "v0.0.12" var versionInfo struct { Local struct {