From 275554e57e31d5bf4505e06101e1c69ef91293ed Mon Sep 17 00:00:00 2001 From: Kailash Nadh Date: Fri, 12 Jul 2019 17:19:26 +0530 Subject: [PATCH] Refactor config error message --- INSTALL.md | 2 +- README.md | 2 +- main.go | 11 +++++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 525b252..b80b8f4 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -2,7 +2,7 @@ - Run `./listmonk --new-config` to generate a sample `config.toml` and add your configuration (SMTP and Postgres DB credentials primarily). - `./listmonk --install` to setup the DB. -- Visit `http://localhost:9000`. +- Run `./listmonk` and visit `http://localhost:9000`. ## Running on Docker diff --git a/README.md b/README.md index eee7321..711819c 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ listmonk is a standalone, self-hosted, newsletter and mailing list manager. It i - Download the [latest release](https://github.com/knadh/listmonk/releases) and extract the listmonk binary somewhere. - Run `./listmonk --new-config` to generate a sample `config.toml` and add your configuration (SMTP and Postgres DB credentials primarily). - `./listmonk --install` to setup the DB. -- Visit `http://localhost:9000`. +- Run `./listmonk` and visit `http://localhost:9000`. - Since there is no user auth yet, it's best to put listmonk behind a proxy like Nginx and setup basicauth on all endpoints except for the few endpoints that need to be public. Here is a [sample nginx config](https://github.com/knadh/listmonk/wiki/Production-Nginx-config) for production use. ### Running on Docker diff --git a/main.go b/main.go index 80a62df..d53bdcd 100644 --- a/main.go +++ b/main.go @@ -85,19 +85,22 @@ func init() { // Generate new config. if ok, _ := f.GetBool("new-config"); ok { if err := newConfigFile(); err != nil { - fmt.Println(err) + logger.Println(err) os.Exit(1) } - fmt.Println("generated config.toml. Edit and run --install") + logger.Println("generated config.toml. Edit and run --install") os.Exit(0) } // Load config files. cFiles, _ := f.GetStringSlice("config") for _, f := range cFiles { - log.Printf("reading config: %s", f) + logger.Printf("reading config: %s", f) if err := ko.Load(file.Provider(f), toml.Parser()); err != nil { - log.Fatalf("error loadng config: %v", err) + if os.IsNotExist(err) { + logger.Fatal("config file not found. If there isn't one yet, run --new-config to generate one.") + } + logger.Fatalf("error loadng config: %v.", err) } } ko.Load(posflag.Provider(f, ".", ko), nil)