diff options
author | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2017-05-17 11:28:57 +0200 |
---|---|---|
committer | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2017-05-17 14:04:32 +0200 |
commit | 40a7183f3b4aa32379aa8b4949f5f9c5e32f79f6 (patch) | |
tree | 25a98c1b6c6c7b5e186ae3cf0dc11807b2fa088a /lib/syncthing/st.go | |
parent | c07adb807c41a1545a9a0f5bbf40080d86946538 (diff) |
Add SDKs support.
Don't allow to install SDKs through XDS for now.
Only probe existing SDKs that have been manually installed using scripts/agl/install-agl-sdks.sh.
Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
Diffstat (limited to 'lib/syncthing/st.go')
-rw-r--r-- | lib/syncthing/st.go | 46 |
1 files changed, 41 insertions, 5 deletions
diff --git a/lib/syncthing/st.go b/lib/syncthing/st.go index 15cab0d..9452fbd 100644 --- a/lib/syncthing/st.go +++ b/lib/syncthing/st.go @@ -27,13 +27,15 @@ type SyncThing struct { APIKey string Home string STCmd *exec.Cmd + STICmd *exec.Cmd // Private fields - binDir string - logsDir string - exitSTChan chan ExitChan - client *common.HTTPClient - log *logrus.Logger + binDir string + logsDir string + exitSTChan chan ExitChan + exitSTIChan chan ExitChan + client *common.HTTPClient + log *logrus.Logger } // ExitChan Channel used for process exit @@ -173,6 +175,28 @@ func (s *SyncThing) Start() (*exec.Cmd, error) { return s.STCmd, err } +// StartInotify Starts syncthing-inotify process +func (s *SyncThing) StartInotify() (*exec.Cmd, error) { + var err error + + s.log.Infof(" STI home=%s", s.Home) + s.log.Infof(" STI url=%s", s.BaseURL) + + args := []string{ + "--home=" + s.Home, + "-target=" + s.BaseURL, + } + if s.log.Level == logrus.DebugLevel { + args = append(args, "-verbosity=4") + } + + env := []string{} + + s.STICmd, err = s.startProc("syncthing-inotify", args, env, &s.exitSTIChan) + + return s.STICmd, err +} + func (s *SyncThing) stopProc(pname string, proc *os.Process, exit chan ExitChan) { if err := proc.Signal(os.Interrupt); err != nil { s.log.Infof("Proc interrupt %s error: %s", pname, err.Error()) @@ -199,6 +223,15 @@ func (s *SyncThing) Stop() { s.STCmd = nil } +// StopInotify Stops syncthing process +func (s *SyncThing) StopInotify() { + if s.STICmd == nil { + return + } + s.stopProc("syncthing-inotify", s.STICmd.Process, s.exitSTIChan) + s.STICmd = nil +} + // Connect Establish HTTP connection with Syncthing func (s *SyncThing) Connect() error { var err error @@ -217,6 +250,9 @@ func (s *SyncThing) Connect() error { if s.client == nil { return fmt.Errorf("ERROR: cannot connect to Syncthing (null client)") } + + s.client.SetLogger(s.log) + return nil } |