forked from toolshed/abra
		
	Add os hook for interrupt signal while waiting for service to converge.
This commit is contained in:
		@ -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
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user