Save Storm DB in the DbPath configured

This commit is contained in:
Deluan 2020-01-10 21:51:57 -05:00 committed by Deluan Quintão
parent cead8906d6
commit c9742181ff
2 changed files with 8 additions and 1 deletions

View File

@ -4,6 +4,7 @@ import (
"sync"
"github.com/cloudsonic/sonic-server/conf"
"github.com/cloudsonic/sonic-server/log"
"github.com/siddontang/ledisdb/config"
"github.com/siddontang/ledisdb/ledis"
)
@ -18,6 +19,7 @@ func Db() *ledis.DB {
once.Do(func() {
config := config.NewConfigDefault()
config.DataDir = conf.Sonic.DbPath
log.Debug("Opening LedisDB from: " + conf.Sonic.DbPath)
l, _ := ledis.Open(config)
instance, err := l.Select(0)
if err != nil {

View File

@ -1,9 +1,12 @@
package db_storm
import (
"path"
"sync"
"github.com/asdine/storm"
"github.com/cloudsonic/sonic-server/conf"
"github.com/cloudsonic/sonic-server/log"
)
var (
@ -13,7 +16,9 @@ var (
func Db() *storm.DB {
once.Do(func() {
instance, err := storm.Open("./storm.db")
dbPath := path.Join(conf.Sonic.DbPath, "storm.db")
instance, err := storm.Open(dbPath)
log.Debug("Opening Storm DB from: " + dbPath)
if err != nil {
panic(err)
}