mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-05-03 22:28:33 +00:00
* Make `logger` a separate module such that don't depend on `shared` module as a whole for logging * Update `Dockerfile`
27 lines
570 B
Go
27 lines
570 B
Go
package utils
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"os/signal"
|
|
"syscall"
|
|
|
|
"github.com/up9inc/mizu/logger"
|
|
)
|
|
|
|
func WaitForFinish(ctx context.Context, cancel context.CancelFunc) {
|
|
logger.Log.Debugf("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():
|
|
logger.Log.Debugf("ctx done")
|
|
break
|
|
case <-sigChan:
|
|
logger.Log.Debugf("Got termination signal, canceling execution...")
|
|
cancel()
|
|
}
|
|
}
|