Skip to content

Commit

Permalink
Make it possible to ctrl+c earlier before handling events
Browse files Browse the repository at this point in the history
This means I can hit ctrl+c while the bucket is still installing, and
still reach the bootstrap wizard.
  • Loading branch information
Robin Sonefors committed Oct 11, 2022
1 parent 7ca5eab commit 76d7151
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions cmd/gitops/beta/run/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@ func runCommandWithoutSession(cmd *cobra.Command, args []string) error {
}

ctx, cancel := context.WithCancel(context.Background())
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM, syscall.SIGUSR1)

log.Actionf("Checking if Flux is already installed ...")

Expand Down Expand Up @@ -566,14 +568,15 @@ func runCommandWithoutSession(cmd *cobra.Command, args []string) error {
// wait for interrupt or ctrl+C
log.Waitingf("Press Ctrl+C to stop GitOps Run ...")

sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM, syscall.SIGUSR1)
sig := <-sigs

cancel()
// create new context that isn't cancelled, for bootstrapping
ctx = context.Background()

// re-enable listening for ctrl+C
signal.Reset(sig)

if err := watcher.Close(); err != nil {
log.Warningf("Error closing watcher: %v", err.Error())
}
Expand Down Expand Up @@ -602,9 +605,6 @@ func runCommandWithoutSession(cmd *cobra.Command, args []string) error {
return nil
}

// re-enable listening for ctrl+C
signal.Reset(sig)

// parse remote
repo, err := bootstrap.ParseGitRemote(log, rootDir)
if err != nil {
Expand Down

0 comments on commit 76d7151

Please sign in to comment.