From 90992bcc039d2b982ad6df18cf3188b53f939368 Mon Sep 17 00:00:00 2001 From: Sebastien Douheret Date: Sat, 7 Oct 2017 23:03:52 +0200 Subject: [PATCH] Kill right Syncthing (same url) in DEBUG_MODE Signed-off-by: Sebastien Douheret --- lib/syncthing/st.go | 3 ++- lib/syncthing/stfolder.go | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/syncthing/st.go b/lib/syncthing/st.go index bc3b101..304cfca 100644 --- a/lib/syncthing/st.go +++ b/lib/syncthing/st.go @@ -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 diff --git a/lib/syncthing/stfolder.go b/lib/syncthing/stfolder.go index d5c74ef..2ad6859 100644 --- a/lib/syncthing/stfolder.go +++ b/lib/syncthing/stfolder.go @@ -72,16 +72,17 @@ func (s *SyncThing) FolderChange(f FolderChangeArg) (string, error) { return "", err } + stClientID := f.SyncThingID // Add new Device if needed var devID protocol.DeviceID - if err := devID.UnmarshalText([]byte(f.SyncThingID)); err != nil { + if err := devID.UnmarshalText([]byte(stClientID)); err != nil { s.log.Errorf("not a valid device id (err %v)", err) return "", err } newDevice := stconfig.DeviceConfiguration{ DeviceID: devID, - Name: f.SyncThingID, + Name: stClientID, Addresses: []string{"dynamic"}, } @@ -102,7 +103,7 @@ func (s *SyncThing) FolderChange(f FolderChangeArg) (string, error) { label = strings.Split(id, "/")[0] } if id = f.ID; id == "" { - id = f.SyncThingID[0:15] + "_" + label + id = stClientID[0:15] + "_" + label } // Resolve local path -- 2.16.6