forked from Daniel.Sy/loic-go
fix(#1): 🐛 Fixed application startup
The main process did not get blocked before. Hence a new channel 'TestDone' is added to be closed when the attack is finished.
This commit is contained in:
parent
600e641560
commit
f02994f32c
2 changed files with 62 additions and 22 deletions
|
|
@ -2,14 +2,15 @@ package cmd
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"forgejo.edf-bootstrap.cx.fg1.ffm.osc.live/Daniel.Sy/loic-go/pkg/loic"
|
||||
"github.com/spf13/cobra"
|
||||
"time"
|
||||
)
|
||||
|
||||
var startCmd = &cobra.Command{
|
||||
Use: "start",
|
||||
Short: "Startet einen Lasttest",
|
||||
Short: "Start an attack",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
targetURL, _ := cmd.Flags().GetString("target")
|
||||
concurrency, _ := cmd.Flags().GetInt("concurrency")
|
||||
|
|
@ -17,6 +18,7 @@ var startCmd = &cobra.Command{
|
|||
rampUp, _ := cmd.Flags().GetDuration("ramp-up")
|
||||
fmt.Printf("Starting test with target %s, concurrency %d, duration %v, ramp-up %v\n", targetURL, concurrency, duration, rampUp)
|
||||
loic.StartTest(targetURL, concurrency, duration, rampUp)
|
||||
<-loic.TestDone
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -25,5 +27,6 @@ func init() {
|
|||
startCmd.Flags().IntP("concurrency", "c", 10, "Maximale Anzahl paralleler Anfragen")
|
||||
startCmd.Flags().DurationP("duration", "d", time.Minute, "Dauer des Tests")
|
||||
startCmd.Flags().DurationP("ramp-up", "r", 30*time.Second, "Zeit für schrittweise Erhöhung der Last")
|
||||
startCmd.MarkFlagRequired("target")
|
||||
rootCmd.AddCommand(startCmd)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue