--- /dev/null
+package configuremgr
+
+import (
+
+ "strings"
+
+ confdescription "configuremgr/description"
+
+ "github.com/fsnotify/fsnotify"
+ "gopkg.in/sconf/ini.v0"
+ "gopkg.in/sconf/sconf.v0"
+)
+
+type ConfigureMgr struct {
+
+ IDeviceDiscoveryMgr struct {
+ PushConfPath func(*confdescription.Doc) (error)
+ }
+
+ IAppExecuteMgr struct {
+ PushConfPath func(*confdescription.Doc) (error)
+ }
+
+ IScoringMgr struct {
+ PushLibPath func(libPath string) (error)
+ }
+
+ Done chan bool
+}
+
+func (cfgMgr *ConfigureMgr) installConfigure(path string) {
+
+//1. libPath, conf := diretoryname get
+//2. push libPath to scoringMgr
+//3. conf context send discoverydevicemgr
+//4. conf context send executeappmgr
+
+ cfg := new(confdescription.Doc)
+
+ libPath, confPath := cfgMgr.getdirname(path)
+ sconf.Must(cfg).Read(ini.File(confPath))
+ cfgMgr.IScoringMgr.PushLibPath(libPath)
+ cfgMgr.IDeviceDiscoveryMgr.PushConfPath(cfg)
+ cfgMgr.IAppExecuteMgr.PushConfPath(cfg)
+
+}
+
+func (cfgMgr *ConfigureMgr) getdirname(path string) (libPath, confPath string) {
+
+ idx := strings.LastIndex(path, "/")
+ if idx == len(path) - 1 {
+ path = path[:len(path)-1]
+ }
+
+ dirname := path[strings.LastIndex(path, "/") + 1:]
+
+ libPath = path + "/" + "lib"+ dirname + ".so"
+ confPath = path + "/" + dirname + ".conf"
+
+ DLog.Println("libPath : " + libPath)
+ DLog.Println("confPath : " + confPath)
+
+ return
+
+}
+
+func (cfgMgr *ConfigureMgr) Watch(path string) {
+
+ watcher, err := fsnotify.NewWatcher()
+ if err != nil {
+ ELog.Fatal(err)
+ }
+ defer watcher.Close()
+
+ go func() {
+ for {
+ select {
+ case event, ok := <-watcher.Events:
+ if !ok {
+ return
+ }
+
+ ELog.Println("log event:", event)
+ if event.Op & fsnotify.Create == fsnotify.Create {
+ cfgMgr.installConfigure(event.Name)
+ }
+ case err, ok := <-watcher.Errors:
+ if !ok {
+ return
+ }
+ ELog.Println("error:", err)
+ }
+ }
+ }()
+
+ err = watcher.Add(path)
+ if err != nil {
+ ELog.Fatal(err)
+ }
+
+
+ <- cfgMgr.Done
+ ILog.Println("configuremgr watch end")
+
+}
\ No newline at end of file