aboutsummaryrefslogtreecommitdiffhomepage
path: root/cli
diff options
context:
space:
mode:
authorGravatar Frédéric Guillot <fred@miniflux.net>2018-08-01 20:28:45 -0700
committerGravatar Frédéric Guillot <fred@miniflux.net>2018-08-01 20:28:45 -0700
commitcf03e0e33859b213f1d7e55b300a074eea107100 (patch)
tree3b88987c42c75b946c4e4b8eeb71fa2359bfe79d /cli
parent17054b396eff571f49812074024cb9db2e098bdc (diff)
Create database package (refactoring)
Diffstat (limited to 'cli')
-rw-r--r--cli/cli.go16
1 files changed, 10 insertions, 6 deletions
diff --git a/cli/cli.go b/cli/cli.go
index 4f5417c..f4014db 100644
--- a/cli/cli.go
+++ b/cli/cli.go
@@ -10,6 +10,7 @@ import (
"github.com/miniflux/miniflux/config"
"github.com/miniflux/miniflux/daemon"
+ "github.com/miniflux/miniflux/database"
"github.com/miniflux/miniflux/logger"
"github.com/miniflux/miniflux/storage"
"github.com/miniflux/miniflux/version"
@@ -33,10 +34,13 @@ func Parse() {
logger.EnableDebug()
}
- store := storage.NewStorage(
- cfg.DatabaseURL(),
- cfg.DatabaseMaxConnections(),
- )
+ db, err := database.NewConnectionPool(cfg.DatabaseURL(), cfg.DatabaseMinConns(), cfg.DatabaseMaxConns())
+ if err != nil {
+ logger.Fatal("Unable to connect to the database: %v", err)
+ }
+ defer db.Close()
+
+ store := storage.NewStorage(db)
if *flagInfo {
info()
@@ -49,7 +53,7 @@ func Parse() {
}
if *flagMigrate {
- store.Migrate()
+ database.Migrate(db)
return
}
@@ -75,7 +79,7 @@ func Parse() {
// Run migrations and start the deamon.
if cfg.RunMigrations() {
- store.Migrate()
+ database.Migrate(db)
}
// Create admin user and start the deamon.