mirror of
https://github.com/chainreactors/spray.git
synced 2025-09-15 11:40:13 +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"`
|
||||
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"`
|
||||
NoStat bool `long:"no-stat" description:"Bool, No stat file output" config:"no-stat"`
|
||||
}
|
||||
|
||||
type RequestOptions struct {
|
||||
@ -719,11 +720,14 @@ func (opt *Option) PrepareRunner() (*Runner, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if !opt.NoStat {
|
||||
r.StatFile.Mod = os.O_WRONLY | os.O_CREATE
|
||||
err = r.StatFile.Init()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
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{}) {
|
||||
t := i.(*Task)
|
||||
if t.origin != nil && t.origin.End == t.origin.Total {
|
||||
if r.StatFile != nil {
|
||||
r.StatFile.SafeWrite(t.origin.Json())
|
||||
}
|
||||
r.Done()
|
||||
return
|
||||
}
|
||||
@ -231,10 +233,14 @@ Loop:
|
||||
if len(r.taskCh) > 0 {
|
||||
for t := range r.taskCh {
|
||||
stat := pkg.NewStatistor(t.baseUrl)
|
||||
if r.StatFile != nil {
|
||||
r.StatFile.SafeWrite(stat.Json())
|
||||
}
|
||||
}
|
||||
}
|
||||
if r.StatFile != nil {
|
||||
logs.Log.Importantf("already save all stat to %s", r.StatFile.Filename)
|
||||
}
|
||||
break Loop
|
||||
case t, ok := <-r.taskCh:
|
||||
if !ok {
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit f1150d00253e0c888976dbfe55cf2669c51f0b58
|
||||
Subproject commit ebc4dc165fccdf3be5745410da7e266fe2135916
|
Loading…
x
Reference in New Issue
Block a user