diff --git a/.gitignore b/.gitignore index 1c0d86791..157b700c0 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ navidrome.toml master.zip Jamstash-master testDB +navidrome.db *.swp *_gen.go dist diff --git a/Dockerfile b/Dockerfile index 1b712a8f0..223844b7f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -44,7 +44,7 @@ COPY --from=gobuilder /tmp/ffmpeg*/ffmpeg /usr/bin/ VOLUME ["/data", "/music"] ENV ND_MUSICFOLDER /music -ENV ND_DBPATH /data/navidrome.db +ENV ND_DATAFOLDER /data ENV ND_SCANINTERVAL 1m ENV ND_LOGLEVEL info ENV ND_PORT 4533 diff --git a/README.md b/README.md index c1e856a87..53b3f263d 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ services: environment: # All options with their default values: ND_MUSICFOLDER: /music - ND_DBPATH: /data/navidrome.db + ND_DATAFOLDER: /data ND_SCANINTERVAL: 1m ND_LOGLEVEL: info ND_PORT: 4533 diff --git a/conf/configuration.go b/conf/configuration.go index e4937dd82..fc9ba7109 100644 --- a/conf/configuration.go +++ b/conf/configuration.go @@ -2,7 +2,9 @@ package conf import ( "flag" + "fmt" "os" + "path/filepath" "github.com/deluan/navidrome/consts" "github.com/deluan/navidrome/log" @@ -12,7 +14,8 @@ import ( type nd struct { Port string `default:"4533"` MusicFolder string `default:"./music"` - DbPath string `default:"./data/navidrome.db"` + DataFolder string `default:"./"` + DbPath string LogLevel string `default:"info"` IgnoredArticles string `default:"The El La Los Las Le Les Os As O A"` @@ -30,13 +33,17 @@ type nd struct { var Server = &nd{} -func LoadFromFile(tomlFile string) { - m := multiconfig.NewWithPath(tomlFile) +func LoadFromFile(confFile string) { + m := multiconfig.NewWithPath(confFile) err := m.Load(Server) if err == flag.ErrHelp { os.Exit(1) } - log.SetLogLevelString(Server.LogLevel) + if Server.DbPath == "" { + Server.DbPath = filepath.Join(Server.DataFolder, "navidrome.db") + } + log.SerLevelString(Server.LogLevel) + log.Trace("Loaded configuration", "file", confFile, "config", fmt.Sprintf("%#v", Server)) } func Load() { diff --git a/log/log.go b/log/log.go index cb502e3e5..da50fde3b 100644 --- a/log/log.go +++ b/log/log.go @@ -35,7 +35,7 @@ func SetLevel(l Level) { logrus.SetLevel(logrus.Level(l)) } -func SetLogLevelString(l string) { +func SerLevelString(l string) { envLevel := strings.ToLower(l) var level Level switch envLevel { diff --git a/persistence/persistence.go b/persistence/persistence.go index 308af361a..f53728214 100644 --- a/persistence/persistence.go +++ b/persistence/persistence.go @@ -31,7 +31,7 @@ func New() model.DataStore { if dbPath == ":memory:" { dbPath = "file::memory:?cache=shared" } - log.Debug("Opening DB from: "+dbPath, "driver", driver) + log.Debug("Opening DataBase", "dbPath", dbPath, "driver", driver) err := initORM(dbPath) if err != nil {