mirror of
https://github.com/chainreactors/spray.git
synced 2025-06-21 18:30:49 +00:00
enhance: add hard exit, https://github.com/chainreactors/spray/issues/78
This commit is contained in:
parent
02162cffd6
commit
de12d568ce
@ -149,6 +149,15 @@ func Spray() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctx, canceler := context.WithTimeout(context.Background(), time.Duration(runner.Deadline)*time.Second)
|
ctx, canceler := context.WithTimeout(context.Background(), time.Duration(runner.Deadline)*time.Second)
|
||||||
|
go func() {
|
||||||
|
select {
|
||||||
|
case <-ctx.Done():
|
||||||
|
time.Sleep(10 * time.Second)
|
||||||
|
logs.Log.Errorf("deadline and timeout not work, hard exit!!!")
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
exitChan := make(chan os.Signal, 2)
|
exitChan := make(chan os.Signal, 2)
|
||||||
signal.Notify(exitChan, os.Interrupt, syscall.SIGTERM)
|
signal.Notify(exitChan, os.Interrupt, syscall.SIGTERM)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user