Skip to content

Commit 81460c9

Browse files
authored
Merge pull request #84 from raffis/fix-user-err
fix: don't panic if no user home was found
2 parents f8bd38c + 22ce5e1 commit 81460c9

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ Get Prometheus MongoDB aggregation query exporter, either as a binaray from the
2424
For kubernetes users there is an official helm chart for the MongoDB query exporter.
2525
Please read the installation instructions [here](https://github.com/raffis/mongodb-query-exporter/blob/master/chart/mongodb-query-exporter/README.md).
2626

27+
### Docker
28+
You can run the exporter using docker (This will start it using the example config provided in the example folder):
29+
```sh
30+
docker run -e MDBEXPORTER_CONFIG=/config/configv3.yaml -v $(pwd)/example:/config ghcr.io/raffis/mongodb-query-exporter:latest
31+
```
32+
2733
## Usage
2834

2935
```

cmd/root.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,12 @@ func initConfig() {
152152
} else {
153153
// Find home directory.
154154
usr, err := user.Current()
155-
if err != nil {
156-
panic(err)
155+
if err == nil {
156+
viper.AddConfigPath(usr.HomeDir + "/.mongodb_query_exporter")
157157
}
158158

159159
// System wide config
160160
viper.AddConfigPath("/etc/mongodb_query_exporter")
161-
// Search config in home directory with name ".mongodb_query_exporter" (without extension).
162-
viper.AddConfigPath(usr.HomeDir + "/.mongodb_query_exporter")
163161
}
164162

165163
viper.SetConfigType("yaml")

0 commit comments

Comments
 (0)