Kill right Syncthing (same url) in DEBUG_MODE
[src/xds/xds-agent.git] / lib / syncthing / st.go
index bc3b101..304cfca 100644 (file)
@@ -131,7 +131,8 @@ func (s *SyncThing) startProc(exeName string, args []string, env []string, eChan
 
        // Kill existing process (useful for debug ;-) )
        if os.Getenv("DEBUG_MODE") != "" {
-               exec.Command("bash", "-c", "pkill -9 "+exeName).Output()
+               fmt.Printf("\n!!! DEBUG_MODE set: KILL existing %s process(es) !!!\n", exeName)
+               exec.Command("bash", "-c", "ps -ax |grep "+exeName+" |grep "+s.BaseURL+" |cut  -d' ' -f 1|xargs -I{} kill -9 {}").Output()
        }
 
        // When not set (or set to '.') set bin to path of xds-agent executable