From ba1e2c442a3b71ccdf79f03c7404d706f5c44c04 Mon Sep 17 00:00:00 2001
From: zhangmeng <775834166@qq.com>
Date: 星期三, 15 一月 2020 14:28:13 +0800
Subject: [PATCH] debug

---
 app/master/master.go |   53 ++++++++++++++++++-----------------------------------
 1 files changed, 18 insertions(+), 35 deletions(-)

diff --git a/app/master/master.go b/app/master/master.go
index d4dd0a6..c4107e9 100644
--- a/app/master/master.go
+++ b/app/master/master.go
@@ -5,7 +5,6 @@
 	"analysis/logo"
 	"analysis/util"
 	"context"
-	"io/ioutil"
 
 	"basic.com/libgowrapper/sdkstruct.git"
 )
@@ -17,52 +16,36 @@
 }
 
 // Run run
-func Run(ctx context.Context, configPath string) bool {
+func Run(ctx context.Context, soFile, configPath string) bool {
 	reaper(ctx)
 
-	rPath := configPath
-	configFile := configPath
-	var fetcher *Fetcher
-
-	fs, _ := ioutil.ReadDir(rPath)
-	for _, file := range fs {
-		if !file.IsDir() {
-			if rPath[len(rPath)-1] != '/' {
-				configFile = rPath + "/" + file.Name()
-			} else {
-				configFile = rPath + file.Name()
-			}
-
-			cfg, err := app.ReadConfig(configFile)
-			if err != nil {
-				logo.Errorln("Run Fetcher Master Read From File: ", configFile, " Config Error: ", err)
-				continue
-			}
-			fetcher = NewFetcher(cfg.SoFile)
-			if fetcher == nil {
-				logo.Errorln("New Fetcher Load so File Funcs Error From File: ", cfg.SoFile)
-				continue
-			}
-		}
-	}
+	fetcher := NewFetcher(soFile)
 	if fetcher == nil {
-		logo.Errorln("!!!!!!Read All So File, But Can't Init DB Fetcher")
+		logo.Errorln("New Fetcher Load so File Funcs Error From File: ", soFile)
 		return false
 	}
 
 	logo.Infoln("~~~~~~Created Fetcher, Now Sync From DB")
 
-	// fetcher.fnInitDBAPI(util.FSI.IP, util.FSI.HTTPort, util.FSI.HBPort, util.FSI.DataPort, logo.Infoln)
-	fetcher.fnInitDBAPI("192.168.20.10", util.FSI.HTTPort, util.FSI.HBPort, util.FSI.DataPort, logo.Infoln)
+	fetcher.fnInitDBAPI(util.FSI.IP, util.FSI.HTTPort, util.FSI.HBPort, util.FSI.DataPort, logo.Infoln)
+	// fetcher.fnInitDBAPI("192.168.20.10", util.FSI.HTTPort, util.FSI.HBPort, util.FSI.DataPort, logo.Infoln)
 	sdks := fetcher.fnSDKInfo()
-
+	for {
+		if len(sdks) == 0 {
+			logo.Errorln("!!!!!!Fetcher Can't Get SDK Infos From Remote DB")
+			continue
+		}
+		break
+	}
 	return manualStart(ctx, sdks, configPath)
 }
 
 func manualStart(ctx context.Context, sdks []sdkstruct.SDKInfo, configPath string) bool {
 	rPath := configPath
 
-	for k, v := range sdks {
+	params := app.GetParams()
+
+	for _, v := range sdks {
 
 		file := rPath + v.SdkType + ".json"
 		if rPath[len(rPath)-1] != '/' {
@@ -84,13 +67,13 @@
 			"-" + util.ConfigPath + "=" + file,
 		}
 
-		args = append(args, app.GetParams(util.ConfigPath, file)...)
-		pid, err := runProc(ctx, "./analysis", args, &cfg.Env)
+		args = append(args, params...)
+		pid, err := runProc(ctx, "./analysis", args, cfg.Env)
 
 		if err != nil {
 			logo.Errorf("ANALYSIS START SLAVE PROC %s IPC: %s error %+v\n", v.SdkType, v.IpcID, err)
 		}
-		logo.Infof("START %d PROC %d SDK %s ID %s\n", k, pid, v.IpcID, v.SdkType)
+		logo.Infof("START SDK %s ID %s PID %d Env: %s\n", v.SdkType, v.IpcID, pid, cfg.Env)
 	}
 	return true
 

--
Gitblit v1.8.0