mirror of https://github.com/k3s-io/k3s.git
hack/e2e.go: listen for Interrupt signal and attempt cleanup if using --down
Signed-off-by: Jess Frazelle <me@jessfraz.com> Signed-off-by: Jess Frazelle <acidburn@google.com>pull/6/head
parent
41f17bd9ac
commit
da786a8dc5
16
hack/e2e.go
16
hack/e2e.go
|
@ -25,6 +25,7 @@ import (
|
|||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"os/signal"
|
||||
"os/user"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
|
@ -159,6 +160,21 @@ func main() {
|
|||
log.Fatalf("Error creating deployer: %v", err)
|
||||
}
|
||||
|
||||
if *down {
|
||||
// listen for signals such as ^C and gracefully attempt to clean up
|
||||
c := make(chan os.Signal, 1)
|
||||
signal.Notify(c, os.Interrupt)
|
||||
go func() {
|
||||
for range c {
|
||||
log.Print("Captured ^C, gracefully attempting to cleanup resources..")
|
||||
if err := deploy.Down(); err != nil {
|
||||
log.Printf("Tearing down deployment failed: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
if err := run(deploy); err != nil {
|
||||
log.Fatalf("Something went wrong: %s", err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue