From 1208438cbaa6d3c5eaabcc68ad3f01391b880010 Mon Sep 17 00:00:00 2001 From: Rich M Date: Sun, 30 Jul 2023 12:28:11 +0100 Subject: [PATCH] Add os hook for interrupt signal while waiting for service to converge. --- pkg/upstream/stack/stack.go | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/pkg/upstream/stack/stack.go b/pkg/upstream/stack/stack.go index 61ee93cf..8ca2c876 100644 --- a/pkg/upstream/stack/stack.go +++ b/pkg/upstream/stack/stack.go @@ -5,6 +5,8 @@ import ( "fmt" "io" "io/ioutil" + "os" + "os/signal" "strings" "time" @@ -454,6 +456,10 @@ func WaitOnService(ctx context.Context, cl *dockerClient.Client, serviceID, appN errChan := make(chan error, 1) pipeReader, pipeWriter := io.Pipe() + sigintChannel := make(chan os.Signal, 1) + signal.Notify(sigintChannel, os.Interrupt) + defer signal.Stop(sigintChannel) + go func() { errChan <- progress.ServiceProgress(ctx, cl, serviceID, pipeWriter) }() @@ -465,6 +471,26 @@ func WaitOnService(ctx context.Context, cl *dockerClient.Client, serviceID, appN select { case err := <-errChan: return err + case <-sigintChannel: + return fmt.Errorf(fmt.Sprintf(` +The wait for %s to converge was interrupted. + +This does not necessarily mean your deployment has stopped, but we aren't +monitoring it anymore + +You can track latest deployment status with: + + abra app ps --watch %s + +And inspect the logs with: + + abra app logs %s + +If a service is failing to even start, try to smoke out the error with: + + abra app errors --watch %s + +`, appName, appName, appName, appName)) case <-time.After(timeout): return fmt.Errorf(fmt.Sprintf(` %s has not converged (%s second timeout reached). @@ -481,7 +507,7 @@ And inspect the logs with: abra app logs %s -If a service is failing to even start, try smoke out the error with: +If a service is failing to even start, try to smoke out the error with: abra app errors --watch %s