mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-05-02 13:56:16 +00:00
* 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
26 lines
522 B
Go
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()
|
|
}
|
|
}
|