Unverified Commit da786a8d authored by Jess Frazelle's avatar Jess Frazelle Committed by Jess Frazelle

hack/e2e.go: listen for Interrupt signal and attempt cleanup if using --down

parent 41f17bd9
...@@ -25,6 +25,7 @@ import ( ...@@ -25,6 +25,7 @@ import (
"log" "log"
"os" "os"
"os/exec" "os/exec"
"os/signal"
"os/user" "os/user"
"path/filepath" "path/filepath"
"strconv" "strconv"
...@@ -159,6 +160,21 @@ func main() { ...@@ -159,6 +160,21 @@ func main() {
log.Fatalf("Error creating deployer: %v", err) 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 { if err := run(deploy); err != nil {
log.Fatalf("Something went wrong: %s", err) log.Fatalf("Something went wrong: %s", err)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment