Allow the config file to be specified in the .env file.
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details

This commit is contained in:
Captain ALM 2022-07-14 22:00:10 +01:00
parent 976d356398
commit 3910d29fa2
Signed by: alfred
GPG Key ID: 4E4ADD02609997B1
1 changed files with 12 additions and 1 deletions

View File

@ -10,6 +10,7 @@ import (
"os"
"os/signal"
"path"
"path/filepath"
"sync"
"syscall"
"time"
@ -48,8 +49,18 @@ func main() {
check(os.MkdirAll(dataDir, 0777))
//Config file processing:
configLocation := os.Getenv("CONFIG_FILE")
if configLocation == "" {
configLocation = path.Join(dataDir, "config.yml")
} else {
if !filepath.IsAbs(configLocation) {
configLocation = path.Join(dataDir, configLocation)
}
}
//Config loading:
configFile, err := os.Open(path.Join(dataDir, "config.yml"))
configFile, err := os.Open(configLocation)
if err != nil {
log.Fatalln("Failed to open config.yml")
}