aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Gopkg.toml4
-rw-r--r--cli/cli.go10
-rw-r--r--config/config.go14
3 files changed, 28 insertions, 0 deletions
diff --git a/Gopkg.toml b/Gopkg.toml
index a046bf3..1a56384 100644
--- a/Gopkg.toml
+++ b/Gopkg.toml
@@ -20,6 +20,10 @@
# name = "github.com/x/y"
# version = "2.4.0"
+[metadata.heroku]
+ root-package = "github.com/miniflux/miniflux"
+ go-version = "go1.10"
+ ensure = "false"
[[constraint]]
name = "github.com/PuerkitoBio/goquery"
diff --git a/cli/cli.go b/cli/cli.go
index 1409229..84c0695 100644
--- a/cli/cli.go
+++ b/cli/cli.go
@@ -67,5 +67,15 @@ func Parse() {
return
}
+ // Run migrations and start the deamon.
+ if cfg.RunMigrations() {
+ store.Migrate()
+ }
+
+ // Create admin user and start the deamon.
+ if cfg.CreateAdmin() {
+ createAdmin(store)
+ }
+
daemon.Run(cfg, store)
}
diff --git a/config/config.go b/config/config.go
index 5bb9cb4..aae1d98 100644
--- a/config/config.go
+++ b/config/config.go
@@ -110,6 +110,10 @@ func (c *Config) DatabaseMaxConnections() int {
// ListenAddr returns the listen address for the HTTP server.
func (c *Config) ListenAddr() string {
+ if port := os.Getenv("PORT"); port != "" {
+ return ":" + port
+ }
+
return c.get("LISTEN_ADDR", defaultListenAddr)
}
@@ -183,6 +187,16 @@ func (c *Config) HasHSTS() bool {
return c.get("DISABLE_HSTS", "") == ""
}
+// RunMigrations returns true if the environment variable RUN_MIGRATIONS is not empty.
+func (c *Config) RunMigrations() bool {
+ return c.get("RUN_MIGRATIONS", "") != ""
+}
+
+// CreateAdmin returns true if the environment variable CREATE_ADMIN is not empty.
+func (c *Config) CreateAdmin() bool {
+ return c.get("CREATE_ADMIN", "") != ""
+}
+
// NewConfig returns a new Config.
func NewConfig() *Config {
return &Config{IsHTTPS: os.Getenv("HTTPS") != ""}