From 9d9cd1d3b93613071d1dffc1c82c4515d2a65af6 Mon Sep 17 00:00:00 2001
From: zhangmeng <775834166@qq.com>
Date: 星期二, 21 一月 2020 17:22:39 +0800
Subject: [PATCH] bug fixed  change real fetcher ip

---
 app/master/daemon.go |   52 ++++++++++++++++++++++++++++++----------------------
 1 files changed, 30 insertions(+), 22 deletions(-)

diff --git a/app/master/daemon.go b/app/master/daemon.go
index 84d626b..88bd840 100644
--- a/app/master/daemon.go
+++ b/app/master/daemon.go
@@ -12,6 +12,22 @@
 	"analysis/util"
 )
 
+const (
+	opRemove = "remove"
+	opAdd    = "add"
+)
+
+// Notice transit to slave
+type Notice struct {
+	Op      string   `json:"Op"`
+	Content []string `json:"Content"`
+}
+
+type transit struct {
+	chNotify chan<- []byte
+	cancel   context.CancelFunc
+}
+
 // NamedProc 鍗曚釜杩涚▼鍚嶅瓧鍜屾湇鍔¢�氶亾
 type NamedProc struct {
 	// 杩涚▼鍚嶅瓧
@@ -32,16 +48,6 @@
 	Typ string
 	// 鍏峰悕杩涚▼
 	SNameProc []NamedProc
-}
-
-// Notice transit to slave
-type Notice struct {
-	Op      string   `json:"Op"`
-	Content []string `json:"Content"`
-}
-type transit struct {
-	chNotify chan<- []byte
-	cancel   context.CancelFunc
 }
 
 // Worker 鍗曚釜杩涚▼鏈嶅姟
@@ -228,31 +234,31 @@
 				for _, w := range workers {
 					if v == w.info.Name {
 						// 鎵惧埌浜嗗搴斿悕瀛楃殑杩涚▼,棣栧厛姹備笉闇�瑕佸啀杩愯鐨勯�氶亾
-						var notice *Notice
 						removes := difference(w.info.Channels, proc.Channels)
 						if len(removes) > 0 {
 							// 閫氱煡瀛愯繘绋嬪叧闂�氶亾
-							notice = &Notice{
-								Op:      "remove",
+							n := Notice{
+								Op:      opRemove,
 								Content: removes,
 							}
-
+							if d, err := json.Marshal(n); err == nil {
+								w.trans.chNotify <- d
+							}
 						}
 
 						// 鍏舵姹傚嚭鏂板鐨勯�氶亾
 						adds := difference(proc.Channels, w.info.Channels)
 						if len(adds) > 0 {
 							// 閫氱煡瀛愯繘绋嬫墦寮�閫氶亾
-							notice = &Notice{
-								Op:      "add",
+							n := Notice{
+								Op:      opAdd,
 								Content: adds,
 							}
-						}
-						if notice != nil {
-							if d, err := json.Marshal(*notice); err == nil {
+							if d, err := json.Marshal(n); err == nil {
 								w.trans.chNotify <- d
 							}
 						}
+
 					}
 				}
 			}
@@ -367,8 +373,10 @@
 
 	if cmd == nil {
 		logo.Errorf("ANALYSIS START SLAVE PROC %s IPC: %s Failed\n", typ, ipcID)
+		return
 	}
 	logo.Infof("START SDK %s ID %s PID %d Env: %s\n", typ, ipcID, cmd.Process.Pid, info.Env)
+	logo.Infoln(cmd.Args)
 
 	ch := make(chan []byte, 3)
 	cancel := fnNotify(ctx, ipcID, ch, logo.Infoln)
@@ -401,9 +409,9 @@
 		os.Setenv(runtime, old)
 	}
 
-	// //debug
-	// cmd.Stdout = os.Stdout
-	// cmd.Stderr = os.Stderr
+	//debug
+	cmd.Stdout = os.Stdout
+	cmd.Stderr = os.Stderr
 	cmd.SysProcAttr = &syscall.SysProcAttr{Pdeathsig: syscall.SIGTERM}
 
 	if err := cmd.Start(); err == nil {

--
Gitblit v1.8.0