From d88b952e9defb42f768b007dc4ce05144e48feaa Mon Sep 17 00:00:00 2001 From: Gregory Eremin Date: Wed, 11 Feb 2015 02:36:08 +0700 Subject: [PATCH] Load units from config --- core/units.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/core/units.go b/core/units.go index 6307dd1..9929772 100644 --- a/core/units.go +++ b/core/units.go @@ -2,6 +2,8 @@ package core import ( "encoding/json" + "io/ioutil" + "os" "github.com/localhots/yeast/impl" "github.com/localhots/yeast/unit" @@ -11,7 +13,16 @@ var ( Units = map[string]Caller{} ) -func LoadUnits(b []byte) { +func LoadUnits() { + f, err := os.Open(Conf().UnitsConfig) + if err != nil { + panic("Failed to open units config: " + Conf().UnitsConfig) + } + b, err := ioutil.ReadAll(f) + if err != nil { + panic("Failed to parse units config: " + Conf().UnitsConfig) + } + var conf map[string]map[string]interface{} json.Unmarshal(b, &conf)