Skip to content

Commit

Permalink
Refactor config error message
Browse files Browse the repository at this point in the history
  • Loading branch information
knadh committed Jul 12, 2019
1 parent 3d3af8c commit 275554e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion INSTALL.md
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -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
Expand Down
11 changes: 7 additions & 4 deletions main.go
Expand Up @@ -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)
Expand Down

0 comments on commit 275554e

Please sign in to comment.