genofire/hs_monolith
genofire
/
hs_monolith
Archived
1
0
Fork 0
This repository has been archived on 2020-09-27. You can view files and clone it, but cannot push or open issues or pull requests.
hs_monolith/models/config.go

35 lines
886 B
Go
Raw Normal View History

2017-03-25 16:09:17 +01:00
package models
import (
"io/ioutil"
"github.com/BurntSushi/toml"
2017-03-30 16:09:44 +02:00
"github.com/genofire/hs_master-kss-monolith/lib/database"
2017-03-30 17:02:20 +02:00
"github.com/genofire/hs_master-kss-monolith/lib/log"
2017-03-25 16:09:17 +01:00
)
//Config the config File of this daemon
type Config struct {
WebserverBind string `toml:"webserver_bind"`
Database database.Config `toml:"database"`
GoodAvailablityTemplate string `toml:"good_availablity_template"`
GoodRelease GoodReleaseConfig `toml:"good_release"`
CacheClean CacheWorkerConfig `toml:"cache_clean"`
2017-03-25 16:09:17 +01:00
}
// ReadConfigFile reads a config model from path of a yml file
func ReadConfigFile(path string) *Config {
config := &Config{}
file, err := ioutil.ReadFile(path)
if err != nil {
2017-03-30 16:09:44 +02:00
log.Log.Panic(err)
2017-03-25 16:09:17 +01:00
}
if err := toml.Unmarshal(file, config); err != nil {
2017-03-30 16:09:44 +02:00
log.Log.Panic(err)
2017-03-25 16:09:17 +01:00
}
return config
}