mirror of
https://github.com/chainreactors/spray.git
synced 2025-09-15 19:50:18 +00:00
support --no-stat flag
This commit is contained in:
parent
3f4094d89e
commit
f942c9c1b3
@ -93,6 +93,7 @@ type OutputOptions struct {
|
|||||||
Quiet bool `short:"q" long:"quiet" description:"Bool, Quiet" config:"quiet"`
|
Quiet bool `short:"q" long:"quiet" description:"Bool, Quiet" config:"quiet"`
|
||||||
NoColor bool `long:"no-color" description:"Bool, no color" config:"no-color"`
|
NoColor bool `long:"no-color" description:"Bool, no color" config:"no-color"`
|
||||||
NoBar bool `long:"no-bar" description:"Bool, No progress bar" config:"no-bar"`
|
NoBar bool `long:"no-bar" description:"Bool, No progress bar" config:"no-bar"`
|
||||||
|
NoStat bool `long:"no-stat" description:"Bool, No stat file output" config:"no-stat"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type RequestOptions struct {
|
type RequestOptions struct {
|
||||||
@ -719,10 +720,13 @@ func (opt *Option) PrepareRunner() (*Runner, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
r.StatFile.Mod = os.O_WRONLY | os.O_CREATE
|
|
||||||
err = r.StatFile.Init()
|
if !opt.NoStat {
|
||||||
if err != nil {
|
r.StatFile.Mod = os.O_WRONLY | os.O_CREATE
|
||||||
return nil, err
|
err = r.StatFile.Init()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return r, nil
|
return r, nil
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,9 @@ func (r *Runner) Prepare(ctx context.Context) error {
|
|||||||
r.Pools, err = ants.NewPoolWithFunc(r.PoolSize, func(i interface{}) {
|
r.Pools, err = ants.NewPoolWithFunc(r.PoolSize, func(i interface{}) {
|
||||||
t := i.(*Task)
|
t := i.(*Task)
|
||||||
if t.origin != nil && t.origin.End == t.origin.Total {
|
if t.origin != nil && t.origin.End == t.origin.Total {
|
||||||
r.StatFile.SafeWrite(t.origin.Json())
|
if r.StatFile != nil {
|
||||||
|
r.StatFile.SafeWrite(t.origin.Json())
|
||||||
|
}
|
||||||
r.Done()
|
r.Done()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -231,10 +233,14 @@ Loop:
|
|||||||
if len(r.taskCh) > 0 {
|
if len(r.taskCh) > 0 {
|
||||||
for t := range r.taskCh {
|
for t := range r.taskCh {
|
||||||
stat := pkg.NewStatistor(t.baseUrl)
|
stat := pkg.NewStatistor(t.baseUrl)
|
||||||
r.StatFile.SafeWrite(stat.Json())
|
if r.StatFile != nil {
|
||||||
|
r.StatFile.SafeWrite(stat.Json())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logs.Log.Importantf("already save all stat to %s", r.StatFile.Filename)
|
if r.StatFile != nil {
|
||||||
|
logs.Log.Importantf("already save all stat to %s", r.StatFile.Filename)
|
||||||
|
}
|
||||||
break Loop
|
break Loop
|
||||||
case t, ok := <-r.taskCh:
|
case t, ok := <-r.taskCh:
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit f1150d00253e0c888976dbfe55cf2669c51f0b58
|
Subproject commit ebc4dc165fccdf3be5745410da7e266fe2135916
|
Loading…
x
Reference in New Issue
Block a user