mirror of
https://github.com/joohoi/acme-dns.git
synced 2025-08-02 16:10:00 +07:00
Added supplementary error checking (#99)
* Added supplementary errorichecking * After running util.go through gofmt * Updated main and util * Minor updates to main and util * Slight refactoring * Add tests
This commit is contained in:
19
main.go
19
main.go
@ -16,13 +16,20 @@ import (
|
||||
|
||||
func main() {
|
||||
// Read global config
|
||||
if fileExists("/etc/acme-dns/config.cfg") {
|
||||
Config = readConfig("/etc/acme-dns/config.cfg")
|
||||
var err error
|
||||
if fileIsAccessible("/etc/acme-dns/config.cfg") {
|
||||
log.WithFields(log.Fields{"file": "/etc/acme-dns/config.cfg"}).Info("Using config file")
|
||||
|
||||
} else {
|
||||
Config, err = readConfig("/etc/acme-dns/config.cfg")
|
||||
} else if fileIsAccessible("./config.cfg") {
|
||||
log.WithFields(log.Fields{"file": "./config.cfg"}).Info("Using config file")
|
||||
Config = readConfig("config.cfg")
|
||||
Config, err = readConfig("./config.cfg")
|
||||
} else {
|
||||
log.Errorf("Configuration file not found.")
|
||||
os.Exit(1)
|
||||
}
|
||||
if err != nil {
|
||||
log.Errorf("Encountered an error while trying to read configuration file: %s", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
setupLogging(Config.Logconfig.Format, Config.Logconfig.Level)
|
||||
@ -32,7 +39,7 @@ func main() {
|
||||
|
||||
// Open database
|
||||
newDB := new(acmedb)
|
||||
err := newDB.Init(Config.Database.Engine, Config.Database.Connection)
|
||||
err = newDB.Init(Config.Database.Engine, Config.Database.Connection)
|
||||
if err != nil {
|
||||
log.Errorf("Could not open database [%v]", err)
|
||||
os.Exit(1)
|
||||
|
Reference in New Issue
Block a user