From b80def47b36d96f6f9c05779a205d17c7c5470e0 Mon Sep 17 00:00:00 2001 From: Graham Clark Date: Sun, 17 Nov 2019 18:46:15 -0500 Subject: [PATCH] Rearrange the loader logging statements. I want the pid included - it makes debugging easier. So I need to wait until the process starts. --- pcap/loader.go | 12 ++++++------ streams/loader.go | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pcap/loader.go b/pcap/loader.go index 76d11fa..7a0cbe1 100644 --- a/pcap/loader.go +++ b/pcap/loader.go @@ -1207,8 +1207,6 @@ func (c *Loader) loadPcapAsync(row int, cb interface{}) { return } - log.Infof("Starting PDML command: %v", c.PdmlCmd) - err = c.PdmlCmd.Start() if err != nil { err = fmt.Errorf("Error starting PDML process %v: %v", c.PdmlCmd, err) @@ -1216,6 +1214,8 @@ func (c *Loader) loadPcapAsync(row int, cb interface{}) { return } + log.Infof("Started PDML command %v with pid %d", c.PdmlCmd, c.PdmlCmd.Pid()) + defer func() { c.PdmlCmd.Wait() }() @@ -1327,8 +1327,6 @@ func (c *Loader) loadPcapAsync(row int, cb interface{}) { return } - log.Infof("Starting pcap command: %v", c.PcapCmd) - err = c.PcapCmd.Start() if err != nil { // e.g. on the pi @@ -1337,6 +1335,8 @@ func (c *Loader) loadPcapAsync(row int, cb interface{}) { return } + log.Infof("Started pcap command %v with pid %d", c.PcapCmd, c.PcapCmd.Pid()) + defer func() { c.PcapCmd.Wait() }() @@ -1681,8 +1681,6 @@ func (c *Loader) loadPsmlAsync(cb interface{}) { return } - log.Infof("Starting PSML command: %v", c.PsmlCmd) - err = c.PsmlCmd.Start() if err != nil { err = fmt.Errorf("Error starting PSML command %v: %v", c.PsmlCmd, err) @@ -1691,6 +1689,8 @@ func (c *Loader) loadPsmlAsync(cb interface{}) { return } + log.Infof("Started PSML command %v with pid %d", c.PsmlCmd, c.PsmlCmd.Pid()) + defer func() { // These need to close so the tailreader Read() terminates so that the // PsmlCmd.Wait() below completes. diff --git a/streams/loader.go b/streams/loader.go index 69896d8..2e8362b 100644 --- a/streams/loader.go +++ b/streams/loader.go @@ -120,8 +120,6 @@ func (c *Loader) loadStreamReassemblyAsync(pcapf string, proto string, idx int, c.streamCmd = c.cmds.Stream(pcapf, proto, idx) - log.Infof("Starting stream reassembly command: %v", c.streamCmd) - streamOut, err := c.streamCmd.StdoutReader() if err != nil { pcap.HandleError(err, cb) @@ -140,6 +138,8 @@ func (c *Loader) loadStreamReassemblyAsync(pcapf string, proto string, idx int, return } + log.Infof("Started stream reassembly command %v with pid %d", c.streamCmd, c.streamCmd.Pid()) + defer func() { err = c.streamCmd.Wait() // it definitely started, so we must wait if !c.SuppressErrors && err != nil { @@ -188,8 +188,6 @@ func (c *Loader) startStreamIndexerAsync(pcapf string, proto string, idx int, ap c.indexerCmd = c.cmds.Indexer(pcapf, proto, idx) - log.Infof("Starting stream indexer command: %v", c.indexerCmd) - streamOut, err := c.indexerCmd.StdoutReader() if err != nil { pcap.HandleError(err, cb) @@ -209,6 +207,8 @@ func (c *Loader) startStreamIndexerAsync(pcapf string, proto string, idx int, ap return } + log.Infof("Started stream indexer command %v with pid %d", c.indexerCmd, c.indexerCmd.Pid()) + defer func() { err = c.indexerCmd.Wait() // it definitely started, so we must wait if !c.SuppressErrors && err != nil {