1
0
Fork 0

Load units from config

This commit is contained in:
Gregory Eremin 2015-02-11 02:36:08 +07:00
parent fccc4df352
commit d88b952e9d
1 changed files with 12 additions and 1 deletions

View File

@ -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)