1
0
mirror of https://github.com/kubeshark/kubeshark.git synced 2025-05-02 13:56:16 +00:00
kubeshark/utils/waitUtils.go
M. Mert Yildiran cb60a4cc4c
🔨 Move cli folder contents into project root ()
* Remove `logger` module

* Remove `shared` module

* Move `cli` folder contents into project root

* Fix linter

* Change the module name from `github.com/kubeshark/kubeshark/cli` to `github.com/kubeshark/kubeshark`

* Set the default `Makefile` rule to `build`

* Add `lint` rule

* Fix the linter errors
2022-11-26 01:17:50 +03:00

26 lines
522 B
Go

package utils
import (
"context"
"log"
"os"
"os/signal"
"syscall"
)
func WaitForFinish(ctx context.Context, cancel context.CancelFunc) {
log.Printf("waiting for finish...")
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
// block until ctx cancel is called or termination signal is received
select {
case <-ctx.Done():
log.Printf("ctx done")
break
case <-sigChan:
log.Printf("Got termination signal, canceling execution...")
cancel()
}
}