Print info message if DATABASE_URL is not set

This commit is contained in:
Frédéric Guillot 2018-02-23 18:26:34 -08:00
parent 73a0a25b6c
commit a9f0fdaf22
2 changed files with 17 additions and 5 deletions

View File

@ -28,6 +28,11 @@ func Parse() {
flag.Parse() flag.Parse()
cfg := config.NewConfig() cfg := config.NewConfig()
if *flagDebugMode || cfg.HasDebugMode() {
logger.EnableDebug()
}
store := storage.NewStorage( store := storage.NewStorage(
cfg.DatabaseURL(), cfg.DatabaseURL(),
cfg.DatabaseMaxConnections(), cfg.DatabaseMaxConnections(),
@ -63,9 +68,5 @@ func Parse() {
return return
} }
if *flagDebugMode || cfg.HasDebugMode() {
logger.EnableDebug()
}
daemon.Run(cfg, store) daemon.Run(cfg, store)
} }

View File

@ -8,6 +8,8 @@ import (
"net/url" "net/url"
"os" "os"
"strconv" "strconv"
"github.com/miniflux/miniflux/logger"
) )
const ( const (
@ -89,7 +91,16 @@ func (c *Config) BasePath() string {
// DatabaseURL returns the database URL. // DatabaseURL returns the database URL.
func (c *Config) DatabaseURL() string { func (c *Config) DatabaseURL() string {
return c.get("DATABASE_URL", defaultDatabaseURL) value, exists := os.LookupEnv("DATABASE_URL")
if !exists {
logger.Info("The environment variable DATABASE_URL is not configured (the default value is used instead)")
}
if value == "" {
value = defaultDatabaseURL
}
return value
} }
// DatabaseMaxConnections returns the number of maximum database connections. // DatabaseMaxConnections returns the number of maximum database connections.