modify debugging
This commit is contained in:
4
.idea/workspace.xml
generated
4
.idea/workspace.xml
generated
@@ -7,7 +7,9 @@
|
||||
<list default="true" id="fc2840de-29dc-4fca-8e0e-a283562f60ca" name="Default Changelist" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/client.go" beforeDir="false" afterPath="$PROJECT_DIR$/client.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/execute.go" beforeDir="false" afterPath="$PROJECT_DIR$/execute.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/cmd/main.go" beforeDir="false" afterPath="$PROJECT_DIR$/cmd/main.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/server.go" beforeDir="false" afterPath="$PROJECT_DIR$/server.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/shared.go" beforeDir="false" afterPath="$PROJECT_DIR$/shared.go" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
||||
@@ -495,6 +495,9 @@ func (c *Client) Start() (err error) {
|
||||
return err
|
||||
}
|
||||
var exit chan int
|
||||
if c.Debug {
|
||||
fmt.Printf("executing command: %s\n", cmd)
|
||||
}
|
||||
c.outputStream, c.errorStream, exit, c.cancel, err = ExecuteAsyncWithCancelReadIndicator(cmd, read)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
69
cmd/main.go
69
cmd/main.go
@@ -5,42 +5,45 @@ import (
|
||||
//"github.com/BGrewell/go-conversions"
|
||||
//"github.com/BGrewell/go-iperf"
|
||||
//"time"
|
||||
"fmt"
|
||||
"github.com/BGrewell/go-conversions"
|
||||
"github.com/BGrewell/go-iperf"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
//s := iperf.NewServer()
|
||||
//c := iperf.NewClient("127.0.0.1")
|
||||
//includeServer := true
|
||||
//c.IncludeServer = &includeServer
|
||||
//fmt.Println(s.Id)
|
||||
//fmt.Println(c.Id)
|
||||
//
|
||||
//err := s.Start()
|
||||
//if err != nil {
|
||||
// fmt.Println(err)
|
||||
//}
|
||||
//
|
||||
//err = c.Start()
|
||||
//if err != nil {
|
||||
// fmt.Println(err)
|
||||
//}
|
||||
//
|
||||
//for c.Running {
|
||||
// time.Sleep(1 * time.Second)
|
||||
//}
|
||||
//
|
||||
//fmt.Println("stopping server")
|
||||
//s.Stop()
|
||||
//
|
||||
//fmt.Printf("Client exit code: %d\n", *c.ExitCode)
|
||||
//fmt.Printf("Server exit code: %d\n", *s.ExitCode)
|
||||
//iperf.Cleanup()
|
||||
//if c.Report.Error != "" {
|
||||
// fmt.Println(c.Report.Error)
|
||||
//} else {
|
||||
// fmt.Printf("Recv Rate: %s\n", conversions.IntBitRateToString(int64(c.Report.End.SumReceived.BitsPerSecond)))
|
||||
// fmt.Printf("Send Rate: %s\n", conversions.IntBitRateToString(int64(c.Report.End.SumSent.BitsPerSecond)))
|
||||
//}
|
||||
s := iperf.NewServer()
|
||||
c := iperf.NewClient("127.0.0.1")
|
||||
c.SetIncludeServer(true)
|
||||
fmt.Println(s.Id)
|
||||
fmt.Println(c.Id)
|
||||
|
||||
err := s.Start()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
err = c.Start()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
for c.Running {
|
||||
time.Sleep(1 * time.Second)
|
||||
}
|
||||
|
||||
fmt.Println("stopping server")
|
||||
s.Stop()
|
||||
|
||||
fmt.Printf("Client exit code: %d\n", *c.ExitCode())
|
||||
fmt.Printf("Server exit code: %d\n", *s.ExitCode)
|
||||
iperf.Cleanup()
|
||||
if c.Report().Error != "" {
|
||||
fmt.Println(c.Report().Error)
|
||||
} else {
|
||||
fmt.Printf("Recv Rate: %s\n", conversions.IntBitRateToString(int64(c.Report().End.SumReceived.BitsPerSecond)))
|
||||
fmt.Printf("Send Rate: %s\n", conversions.IntBitRateToString(int64(c.Report().End.SumSent.BitsPerSecond)))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -56,9 +56,6 @@ func (r *Reporter) runLogProcessor() {
|
||||
if err != nil {
|
||||
log.Fatalf("failed to tail log file: %v", err)
|
||||
}
|
||||
if DEBUG {
|
||||
log.Printf("starting to watch log file: %s\n", r.LogFile)
|
||||
}
|
||||
|
||||
for {
|
||||
select {
|
||||
@@ -66,16 +63,10 @@ func (r *Reporter) runLogProcessor() {
|
||||
if line == nil {
|
||||
continue
|
||||
}
|
||||
if DEBUG {
|
||||
log.Printf("new line: %s\n", line)
|
||||
}
|
||||
if len(line.Text) > 5 {
|
||||
id := line.Text[1:4]
|
||||
stream, err := strconv.Atoi(strings.TrimSpace(id))
|
||||
if err != nil {
|
||||
if DEBUG {
|
||||
log.Printf("error converting stream id to int: %v\n", err)
|
||||
}
|
||||
continue
|
||||
}
|
||||
fields := strings.Fields(line.Text[5:])
|
||||
@@ -126,9 +117,6 @@ func (r *Reporter) runLogProcessor() {
|
||||
Omitted: omitted,
|
||||
}
|
||||
r.ReportingChannel <- report
|
||||
if DEBUG {
|
||||
log.Println("added report to reporting channel")
|
||||
}
|
||||
}
|
||||
}
|
||||
case <-time.After(100 * time.Millisecond):
|
||||
|
||||
@@ -156,6 +156,9 @@ func (s *Server) Start() (err error) {
|
||||
return err
|
||||
}
|
||||
var exit chan int
|
||||
if s.Debug {
|
||||
fmt.Printf("executing command: %s\n", cmd)
|
||||
}
|
||||
s.outputStream, s.errorStream, exit, s.cancel, err = ExecuteAsyncWithCancel(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user