mirror of
https://github.com/chainreactors/spray.git
synced 2026-10-28 19:40:49 +00:00
support --no-stat flag
This commit is contained in:
1 parent
e2f2383bf6
commit
749a0159a6
3 files changed
+18
-8
No files matched your search
+8
-4
@@ -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,10 +720,13 @@ func (opt *Option) PrepareRunner() (*Runner, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
r.StatFile.Mod = os.O_WRONLY | os.O_CREATE
|
||||
err = r.StatFile.Init()
|
||||
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
|
||||
}
|
||||
|
||||
+9
-3
@@ -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 {
|
||||
r.StatFile.SafeWrite(t.origin.Json())
|
||||
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)
|
||||
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
|
||||
case t, ok := <-r.taskCh:
|
||||
if !ok {
|
||||
|
||||
+1
-1
Submodule templates updated: f1150d0025...ebc4dc165f.
Reference in new issue
Block a user